I have many php pages which have different forms. I want to submit all the forms to a page called insertproc.php in which I call my stored procedures to insert the data. However I am submitting the form data using jquery.Should I set session variables in jquery script after every form submission ? or can I acheive this with some other functionality. example: if I have 3 pages say page1.php, page2.php, page3.php which has one form each say form1.php, form2.php, form3.php. I have to submit all 3 forms to insertproc.php. In insertproc.php I have check from which form I have submitted. Accordingly I have to run that respective stored procedure. Should I set some session variable in jquery after I submit a form say
$Session['proc_name'] = 'insert_user';
and check in insertproc.php the value of the session variable to call its respective stored procedure. Please guide me how I can achieve this functionality.
If you submit your form with jQuery you can add another input field to your
<form>
element which says which form is it, for example,form1.php
:form2.php
:etc.
Then you can easily check in your PHP code where did the submitted values come from by checking
$_POST['source']
. No need for sessions. Actually sessions could be source of errors here - what if someone will openform1
, not submit, openform2
in another tab, come back toform1
and submitform1
? I guess session variable would contain value fromform2
instead ofform1
.