jgurgen Posted February 23, 2007 Share Posted February 23, 2007 after a user clicks submit on a form i would like them to be redirected to the same page with a display of confirmation if it was successful and if unsuccessful display error message. how do i do this?? Link to comment https://forums.phpfreaks.com/topic/39740-return-to-form-after-submit/ Share on other sites More sharing options...
JBS103 Posted February 23, 2007 Share Posted February 23, 2007 Set the action in the form tag to the page where you want to go after submission (In this case, it is the same page that the form is on). Then, with a little PHP code block, check if the submit button is pressed. If it was, check to make sure the submission is valid and display either success or failure. <?php if(isset($_POST['Submit'])) //Or check a hidden value { //Run checks for validity here if(everything valid) { echo "Success"; //Continue } else { echo "Failure"; //Exit } } ?> ... <form action="thispage.html" ... > ... Link to comment https://forums.phpfreaks.com/topic/39740-return-to-form-after-submit/#findComment-191872 Share on other sites More sharing options...
jgurgen Posted February 23, 2007 Author Share Posted February 23, 2007 i have the form going to a form submit page where all forms on the site will go. after the calculations are done i want to redirect back to the form and display the result. would it be better to do all the form submition on the same page as the form so i am able to do this? Link to comment https://forums.phpfreaks.com/topic/39740-return-to-form-after-submit/#findComment-191873 Share on other sites More sharing options...
tippy_102 Posted February 23, 2007 Share Posted February 23, 2007 Sounds like you need action="<?=$PHP_SELF?>" and something like <input type="hidden" name="submitted" value="yes" /> The check for the value of the submitted string if ($submitted =="yes") { ..stuff here... If you have trouble, paste your code and we'll try to help. Link to comment https://forums.phpfreaks.com/topic/39740-return-to-form-after-submit/#findComment-191874 Share on other sites More sharing options...
jgurgen Posted February 23, 2007 Author Share Posted February 23, 2007 EditDistrict.php Form submits to Form_Submit.php <form name="form1" method="Post" action="Form_Submit.php"> <input type="hidden" name="PageName" value="EditDistrict" /> <table> <tr><td>District Name: </td><td><input type="text" name="DistrictName" value="<?php echo $DName ?>"></td></tr> <tr><td>District ShortName:</td><td><input type="text" name="DistrictShort" value="<?php echo $DShort ?>"></td></tr> <tr><td>District Website:</td><td><input type="text" name="DistrictWebSite" value="<?php echo $DWeb ?>"></td></tr> <tr bgcolor="#FFFF00"><td>Primary Contact Information</td></tr> <tr><td>First Name: </td><td><input type="text" name="P_First" value="<?php echo $PFirst ?>"></td></tr> <tr><td>Last Name: </td><td><input type="text" name="P_Last" value="<?php echo $PLast ?>"></td></tr> <tr><td>Phone Number: </td><td><input type="text" name="P_Phone" value="<?php echo $PPhone ?>"></td></tr> <tr><td>Email: </td><td><input type="text" name="P_Email" value="<?php echo $PEmail ?>"></td></tr> <tr bgcolor="#FFFF00"><td>Secondary Contact Information</td></tr> <tr><td>First Name: </td><td><input type="text" name="S_First" value="<?php echo $SFirst ?>"></td></tr> <tr><td>Last Name: </td><td><input type="text" name="S_Last" value="<?php echo $SLast ?>"></td></tr> <tr><td>Phone Number: </td><td><input type="text" name="S_Phone" value="<?php echo $SPhone ?>"></td></tr> <tr><td>Email: </td><td><input type="text" name="S_Email" value="<?php echo $SEmail ?>"></td></tr> <tr><td><input name="Confirm" type="submit" value="Submit"></td></tr> </table> </form> Form_Submit.php Here is where i was to do all mysql commands and return to EditDistrict.php with Success or Failure <?php // PHP processes all form submitions // Get page that submitted data $PageName = $_REQUEST['PageName']; ////////////// // District // ////////////// if($PageName = 'EditDistrict') { $DName=$_REQUEST['District_Name']; $DShort=$_REQUEST['District_ShortName']; $DWeb=$_REQUEST['District_WebSite']; $PFirst=$_REQUEST['Contact_First']; $PLast=$_REQUEST['Contact_Last']; $PPhone=$_REQUEST['Contact_Phone']; $PEmail=$_REQUEST['Contact_Email']; $SFirst=$_REQUEST['SecContact_First']; $SLast=$_REQUEST['SecContact_Last']; $SPhone=$_REQUEST['SecContact_Phone']; $SEmail=$_REQUEST['SecContact_Email']; header("Location: http://www.hsrhlofli.com/admin/Edit_District.php"); } Link to comment https://forums.phpfreaks.com/topic/39740-return-to-form-after-submit/#findComment-191876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.