I spent the whole morning trying to figure out how to create an extra variable in a html page and sent it to a form processing php script . "<input type="text", name="firstname" size =" 34">" this creates a variable "firstname" which can be collected for processing in a php script as $_POST["firstname"] , but along with this say I also want to sent the text "this is coming for form 1" how do I do that . I just can't generate a text box and put the text in there and then sent it thats would be pretty stupidd ... So how do i generate a variable to hold this value in a webpage .. PLease helpp !!!
Thanks in Advance ; Francis Pereira
Sometime Today, F cobbled together some glyphs to say:
"<input type="text", name="firstname" size =" 34">" this creates a variable "firstname" which can be collected for processing in a php script as $_POST["firstname"] , but along with this say I also want to sent the text "this is coming for form 1" how do I do that . I just can't generate a text
assuming you have 2 (or 3 or n) forms on your page, set the action accordingly:
<form method="get" action="myscript.php?form=1"> ... </form>
<form method="post" action="myscript.php?form=2"> ... </form> ...
in your script, check the value of $_GET['form'].
if (and only if) you need it to be secure and unpredictable, then use an md5 hash in each case instead of 1 and 2. You'll have to store the hash on the back end as well as change it for every call to the page.
Philip
Philip Tellis wrote:
Sometime Today, F cobbled together some glyphs to say:
"<input type="text", name="firstname" size =" 34">" this creates a variable "firstname" which can be collected for processing in a php script as $_POST["firstname"] , but along with this say I also want to sent the text "this is coming for form 1" how do I do that . I just can't generate a text
assuming you have 2 (or 3 or n) forms on your page, set the action accordingly:
<form method="get" action="myscript.php?form=1"> ... </form>
<form method="post" action="myscript.php?form=2"> ... </form> ...
in your script, check the value of $_GET['form'].
if (and only if) you need it to be secure and unpredictable, then use an md5 hash in each case instead of 1 and 2. You'll have to store the hash on the back end as well as change it for every call to the page.
Philip
Philip ,
Here is what my form post looks like <form name="1form"
onSubmit="return form_Validator(this)" mothod="post" action="test.php?who=itsmeheheheheheehe"> and my test.php is : echo $_GET['who']; yet I dont get any value for who on the page . Francis
Sometime on Jan 27, F cobbled together some glyphs to say:
Here is what my form post looks like <form name="1form"
onSubmit="return form_Validator(this)" mothod="post" action="test.php?who=itsmeheheheheheehe"> and my test.php is : echo $_GET['who']; yet I dont get any value for who on the page .
Try $_REQUEST['who']
btw, do you have a variable in your form that is also called who?
Philip Tellis wrote:
Sometime on Jan 27, F cobbled together some glyphs to say:
Here is what my form post looks like <form name="1form"
onSubmit="return form_Validator(this)" _mothod="post"_ action="test.php?who=itsmeheheheheheehe"> and my test.php is : echo $_GET['who']; yet I dont get any value for who on the page .
Try $_REQUEST['who']
btw, do you have a variable in your form that is also called who?
Hey Philip , The $_GET['who'] finally worked . There was a mistake in the word "method" . Pretty stupid thing to do ... But the funny thing is thats the other variables were coming through !!!! QAnyway ........... Thanks a lot for the HELP all you guys !!! Have a Lovely weekend !!!! Thanks once again ... Francis Pereira !!
On 1/27/06, Philip Tellis philip.tellis@gmx.net wrote:
Sometime Today, F cobbled together some glyphs to say:
"<input type="text", name="firstname" size =" 34">" this creates a variable "firstname" which can be collected for processing in a php script as $_POST["firstname"] , but along with this say I also want to sent the text "this is coming for form 1" how do I do that . I just can't generate a text
assuming you have 2 (or 3 or n) forms on your page, set the action accordingly:
<form method="get" action="myscript.php?form=1"> ... </form>
<form method="post" action="myscript.php?form=2"> ... </form> ...
in your script, check the value of $_GET['form'].
Assuming that you have a submit button in each of your forms, another approach would be to use the same name attribute for the different submit buttons, with different values for the value attribute in different forms. Something like:
<html> <title>forms</title> <body>
<form method="POST"> <input type=submit value="Submit 1" name="op"> </form>
<form method="POST"> <input type=submit value="Submit 2" name="op"> </form>
<form method="POST"> <input type=submit value="Submit 3" name="op"> </form>
<?php
if(isset($_POST["op"])) { echo "You submitted <b>" . $_POST["op"] . "</b>"; }
?>
</body> </html>
Sometime on Jan 27, NK cobbled together some glyphs to say:
Assuming that you have a submit button in each of your forms, another approach would be to use the same name attribute for the different submit buttons, with different values for the value attribute in
doesn't translate well. this will bite you in the backside when you want to internationalise your site. better is to have a different name for the submit button. then you just check for the existence of that variable:
<form ...> <input type="submit" name="form1-submit"> </form>
<form ...> <input type="submit" name="form2-submit"> </form>
PHP:
if(isset($_REQUEST['form1-submit'])) { // form1 } elseif(isset($_REQUEST['form2-submit'])) { // form2 }
Philip Tellis wrote:
Sometime on Jan 27, NK cobbled together some glyphs to say:
Assuming that you have a submit button in each of your forms, another approach would be to use the same name attribute for the different submit buttons, with different values for the value attribute in
doesn't translate well. this will bite you in the backside when you want to internationalise your site. better is to have a different name for the submit button. then you just check for the existence of that variable:
<form ...> <input type="submit" name="form1-submit"> </form>
<form ...> <input type="submit" name="form2-submit"> </form>
PHP:
if(isset($_REQUEST['form1-submit'])) { // form1 } elseif(isset($_REQUEST['form2-submit'])) { // form2 }
Yep !!! I could catch the value of the submit button THANKSSS a lot for that , though Philip I am still trying to manually sent the variable through the url and its not yet working . I tried $_REQUEST to catch the variable but it did not work either !! Any ideas as to what may be wrong ......
Francis Pereira !!
Sometime Today, F cobbled together some glyphs to say:
that , though Philip I am still trying to manually sent the variable through the url and its not yet working . I tried $_REQUEST to catch the
have a look at the actual HTTP request going through. Get yourself Firefox's live HTTP headers extension that will tell you what the browser sends to the server. Let us know the complete HTTP data that goes through.
Philip
Sometime on Fri, Jan 27, 2006 at 05:24:49PM +0530, Francis said:
I spent the whole morning trying to figure out how to create an extra variable in a html page and sent it to a form processing php script . "<input type="text", name="firstname" size =" 34">" this creates a variable "firstname" which can be collected for processing in a php script as $_POST["firstname"] , but along with this say I also want to
You could send the data inside a hidden field, if that's what you are trying to do.
<input type="hidden" name="hidden_field" value="coming from foo">
You can refer this by $_POST['hidden_field'] if the document got posted.
Anurag
Anurag wrote:
Sometime on Fri, Jan 27, 2006 at 05:24:49PM +0530, Francis said:
I spent the whole morning trying to figure out how to create an extra variable in a html page and sent it to a form processing php script . "<input type="text", name="firstname" size =" 34">" this creates a variable "firstname" which can be collected for processing in a php script as $_POST["firstname"] , but along with this say I also want to
You could send the data inside a hidden field, if that's what you are trying to do.
<input type="hidden" name="hidden_field" value="coming from foo">
You can refer this by $_POST['hidden_field'] if the document got posted.
Anurag
Hey Anurag !! Thats a nice way of doing it !! Will certainly use it in my pages but I also got to figure out Philip's way of sending variables through the url .
Francis Pereira