Forms!

If I have a form with two buttons, how can I get them to both read in the values BUT also have them call different pages?<br />
<br />
<br />
<form method="post" action="/Guestbook.php?func=sign"><br />
<br />
<br />
<input type="text" name="name" value="" maxlength="60" size="60" /><br />
<br />
<input type="submit" value="Submit" /> <! --- This one calls the page specified in action<br />
<input type="submit" value="Preview" /><! --- how do I get this one to read in the values and call a different page?<br />
<br />
</form><!--content--><form name="myForm" method="post" action=""><br />
<br />
<br />
<input type="text" name="name" value="" maxlength="60" size="60" /><br />
<br />
<input type="button" value="Submit" onclick="d=document.forms['myForm'];d.action='/Guestbook.php?func=sign';d.submit();" /> <! --- This one calls the page specified in action<br />
<input type="button" value="Preview" onclick="d=document.forms['myForm'];d.action='/differentpage herewithadditionalinformationtiedtoit';d.submit();" /> <! --- how do I get this one to read in the values and call a different page?<br />
<br />
</form><br />
<br />
<br />
a couple things though...<br />
<br />
one, all of the element's will be sent to the php page in question and since the form's method="post" then the information wont be displayed in the user's address bar but php will still have the information... basically, in your example, both pages ( when called ) will have a $name scalar ( string )<br />
<br />
and two, son't forget ( for security reasons ) to check the information sent to these pages in the php files to insure that no malais code is sent there instead of relying on any kind of javascript form validation. for mor info on that, check out the php language and server side forums, they have a lot of information...<br />
<br />
perhaps one of the mods may post a link for you to some of the threads where they discuss this topic very thoroughly ;)<!--content-->for one lose this<br />
<br />
<form method="post" action="/Guestbook.php?func=sign"><br />
<br />
if you are sending POSTed variable then a get is not doing you any good. you will have problem down the road.<br />
<br />
second why have the second button submitted to a different page? if you use php have it send to the same page.<br />
<br />
also this way will be easy as all you have to do is check for the preview button to be submitted then just go from there.<br />
<br />
if you want to catch the actual submit then change the name of the submit button to "signin" or something.<!--content-->
 
Back
Top