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

...

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.