Changing form action using php -
`i have put form allowing people register event online. form has validation inputs , sends $_post values insert form , insert form sends data of mysql database. works fine.
but want send data on if email , confirm emails match. if match, form sends $_post data insert form; if don't match form represented user.
stack overflow (oct 27, 2012) suggested: <form action =<?php echo $action; ?>
".
i can't following code affect form action:
<?php print_r($_post); if($_post['email'] !== $_post['emailconf']) { //echo "they not equal"; $action = "serrainsertform.php"; } else { //echo "they equal"; $action = "serraregformcomplete.php"; } ?>
notes: want php. have not used javascript before. print_r show $_post value ok echo statements follow logic of if statements tried use different redirects in place of $action didn't work
i appreciate suggestions
update:
based on update question. maybe use this?
if ($_post['email'] !== $_post['emailconf']) { //echo "they not equal"; include("serrainsertform.php"); } else { //echo "they equal"; include("serraregformcomplete.php"); }
this allow keep form in "insertform" file, , code completion in "formcomplete" file.
original:
php processed on server side. user input cannot change form settings (without javascript) on client side. being said since javascript can disabled (or modified in console), write sort of php check sever validate well.
my basic code form such :
$bshowform = true; if (isset($_post['email'])) { if ($_post['email'] == $_post['emailconf']) { $bshowform = false; ... process form ... ... on process error, set error message , set bshowform true ... ... show thank message ... } else { ... set error message ... } } if ($bshowform) { ... if error message, display ... ... form html ... }
Comments
Post a Comment