Jump to content

Return to form after submit


jgurgen

Recommended Posts

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" ... >

...

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?

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.

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");
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.