Jump to content

Redirect to the bottom of the page after a FORM POST


Madmaxx68

Recommended Posts

I am trying to get a form to redirect to the bottom of the page after the form has been submitted. After the form is submitted it shows all the content from the original page and then confirmation dialog at the bottom. I would like the page to reload and skip to the bottom so the user can see the confirmation without having to scroll the page.

Here is the code I am working with. Sorry for the length.

<?

$form_block = "<FORM METHOD=\"POST\" ACTION=\"$_SERVER[php_SELF]\">

 

<P><strong><font size=\"+2\" color=\"red\"><b>*</b></font>Name: <font size=\"-1\" color=\"red\">(First and Last)</font></strong>

<INPUT type=\"text\" NAME=\"sender_name\"

VALUE=\"" . str_replace("\\'","'",str_replace("\\\"",""",$_POST[sender_name])) . "\" SIZE=30 MAXLENGTH=30></P>

 

<p><strong><font  size=\"+2\" color=\"red\">*</font>Mailing Address:</strong>

<INPUT type=\"text\" NAME=\"sender_address\"

VALUE=\"" . str_replace("\\'","'",str_replace("\\\"",""",$_POST[sender_address])) . "\" SIZE=50 MAXLENGTH=50></P>

 

<P><strong><font size=\"+2\" color=\"red\"><b>*</b></font>Phone Number: <font size=\"-1\" color=\"red\">(ex.XXX-XXX-XXXX)</font></strong>

<INPUT type=\"text\" NAME=\"phone_number\"

VALUE=\"" . str_replace("\\'","'",str_replace("\\\"",""",$_POST[phone_number])) . "\" SIZE=12 MAXLENGTH=12></P>

 

<p><strong><font size=\"+2\" color=\"red\"><b>*</b></font>Are you a Benton REA Member: </strong>

Yes: <input type=\"radio\" name=\"radiogroup\" value=\"Yes\" >&nbsp&nbsp

No: <input type=\"radio\" name=\"radiogroup\" value=\"No\"

VALUE=\"$_POST[radiogroup]\"><br>

<font size = \"-1\">&nbsp(Membership is determined by whether you purchase your electricity from Benton Rural Electric Association.  If yes, please provide your member number or account number.)</font><br>

</p>

 

<P>&nbsp&nbsp<strong>BREA Member Number  <font size=\"-1\" color=\"red\">(<a href=\"../images/memcard.jpg\" target=\"_blank\">View an example</a>)</font>  or Account Number  <font size=\"-1\" color=\"red\">(<a href=\"../../images/reabill.jpg\" target=\"_blank\">View an example</a>)</font>: </strong>

<INPUT type=\"text\" NAME=\"member_number\"

VALUE=\"" . str_replace("\\'","'",str_replace("\\\"",""",$_POST[member_number])) . "\" SIZE=12 MAXLENGTH=12></P>

 

<p><strong><font size=\"+2\" color=\"red\"><b>*</b></font>E-Mail Address:</strong>

<INPUT type=\"text\" NAME=\"sender_email\"

VALUE=\"" . str_replace("\\'","'",str_replace("\\\"",""",$_POST[sender_email])) . "\" SIZE=30 MAXLENGTH=30></P>

 

<p>&nbsp&nbsp<strong>Do you need a Membership Card?: </strong>Yes: <input type=\"radio\" name=\"radiogroup1\" value=\"Yes\" >&nbsp&nbsp

No: <input type=\"radio\" name=\"radiogroup1\" value=\"No\" VALUE=\"$_POST[radiogroup1]\"><br>

<font size = \"-1\">&nbsp(If you have lost or misplaced your card or have not received your card yet.)</font></p>

 

<p><strong><font size=\"+2\" color=\"red\">*</font>What class would you like to attend?:</strong>

<SELECT NAME=\"class_date\">

<option selected></option>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'January 21 - Intro to Windows 7 - WR'? ' selected ' : ' ')."VALUE=\"January 21 - Intro to Windows 7 - WR\">January 21 - Intro to Windows 7 - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'February 18 - Intro to Windows 7 - Prosser'? ' selected ' : ' ')."VALUE=\"February 18 - Intro to Windows 7 - Prosser\">February 18 - Intro to Windows 7 - Prosser</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'March 18 - Internet for Families - WR'? ' selected ' : ' ')."VALUE=\"March 18 - Internet for Families - WR\">March 18 - Internet for Families - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'April 22 - Internet for Families - Prosser'? ' selected ' : ' ')."VALUE=\"April 22 - Internet for Families - Prosser\">April 22 - Internet for Families - Prosser</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'May 20 - Internet Security - WR'? ' selected ' : ' ')."VALUE=\"May 20 - Internet Security - WR\">May 20 - Internet Security - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'June 17 - Internet Security - Prosser'? ' selected ' : ' ')."VALUE=\"June 17 - Internet Security - Prosser\">June 17 - Internet Security - Prosser</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'July 1 - 12pm to 2pm - Windows 7 for Business Users - WR'? ' selected ' : ' ')."VALUE=\"July 1 - 12pm to 2pm - Windows 7 for Business Users - WR\">July 1 - 12pm to 2pm - Windows 7 for Business Users - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'July 1 - 6pm to 8pm - Windows 7 for Business Users - WR'? ' selected ' : ' ')."VALUE=\"July 1 - 6pm to 8pm - Windows 7 for Business Users - WR\">July 1 - 6pm to 8pm - Windows 7 for Business Users - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'July 22 - Advanced Windows 7 - WR'? ' selected ' : ' ')."VALUE=\"July 22 - Advanced Windows 7 - WR\">July 22 - Advanced Windows 7 - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'August 19 - Advanced Windows 7 - Prosser'? ' selected ' : ' ')."VALUE=\"August 19 - Advanced Windows 7 - Prosser\">August 19 - Advanced Windows 7 - Prosser</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'September 16 - Advanced Email & WebMail - WR'? ' selected ' : ' ')."VALUE=\"September 16 - Advanced Email & WebMail - WR\">September 16 - Advanced Email & WebMail - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'October 21 - Advanced Email & WebMail - Prosser'? ' selected ' : ' ')."VALUE=\"October 21 - Advanced Email & WebMail - Prosser\">October 21 - Advanced Email & WebMail - Prosser</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'November 18 - MS Office 2010/Word 2010 - WR'? ' selected ' : ' ')."VALUE=\"November 18 - MS Office 2010/Word 2010 - WR\">November 18 - MS Office 2010/Word 2010 - WR</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'December 16 - MS Office 2010/Word 2010 - Prosser'? ' selected ' : ' ')."VALUE=\"December 16 - MS Office 2010/Word 2010 - Prosser\">December 16 - MS Office 2010/Word 2010 - Prosser</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'Wait List'? ' selected ' : ' ')."VALUE=\"Wait List\">Wait List</OPTION>

<OPTION".(isset($_POST[class_date]) && $_POST[class_date] == 'Comment'? ' selected ' : ' ')."VALUE=\"Comment\">I would like to make a comment.</OPTION>

</SELECT>

 

<p><strong>Comments:</strong><br>

<TEXTAREA NAME=\"comments\" cols=50 rows=3 wrap=hard>" . str_replace("\\'","'",str_replace("\\\"",""",$_POST[comments])) . "</textarea></P>

 

<INPUT type=\"hidden\" name=\"op\" value=\"ds\">

 

<P><Input type=\"submit\" name=\"submit\" value=\"Submit your request\"></P>

</form>";

 

$send ="yes";

 

if ($_POST[op] != "ds" ) {

    //they need to see the form

    echo "$form_block";

}

else if ($_POST[op] == "ds" ) {

    //check value of $_POST[sender_name]

 

    if (($_POST[sender_name] == "" )  or (strlen($_POST[sender_name]) > 30) or !(strpos($_POST[sender_name],"\"") === false)) {

        $name_err = "<font color=red size=+2>Please enter your First and Last Name.</font><br>";

        $send = "no";

    }

        //check value of $_POST[sender_address]

 

    if (($_POST[sender_address] == "" )  or (strlen($_POST[sender_address]) > 30) or !(strpos($_POST[sender_address],"\"") === false)) {

        $address_err = "<font color=red size=+2>Please enter your Mailing Address.</font><br>";

        $send = "no";

    }

 

        //check value of $_POST[phone_number]

 

    if (($_POST[phone_number] == "" )  or (strlen($_POST[phone_number]) > 30) or !(strpos($_POST[phone_number],"\"") === false)) {

        $phone_err = "<font color=red size=+2>Please enter your Phone Number.</font><br>";

        $send = "no";

    }

        //check value of $_POST[checkgroup]

 

    if ($_POST[radiogroup] == "" ) {

        $mem_err = "<font color=red size=+2>Please tell us if you are a BREA Member.</font><br>";

        $send = "no";

    }

        //check value of $_POST[member_number]

 

    if ((strlen($_POST[member_number]) > 30) or !(strpos($_POST[member_number],"\"") === false)) {

        $memnum_err = "<font color=red size=+2>Please enter your your Member Number.</font><br>";

        $send = "no";

    }

    //check value of $_POST[sender_email]

 

    if (($_POST[sender_email] == "" )  or (strlen($_POST[sender_email]) > 30) or !(strpos($_POST[sender_email],"\"") === false)) {

        $email_err = "<font color=red size=+2>Please enter your E-mail Address.</font><br>";

        $send = "no";

    }

        //check value of $_POST[exp_month]

 

    if ($_POST[class_date] == "" ) {

        $class_err = "<font color=red size=+2>Please choose a class date or other option.</font><br>";

        $send = "no";

    }

    //check value of $_POST[comments]

 

    if ((strlen($_POST[comments]) > 200) or !(strpos($_POST[comments],"\"") === false)) {

        $comm_err = "<font color=red size=+2>Please keep your comments under 200 characters including spaces and remove any special characters.</font><br>";

        $send = "no";

    }

    if ($send != "no") {

        // building the e-mail

    $msg = "Make sure to send a confirmation email to this requestor. \n \n";

    $msg .= "Community Classes\n";

    $msg .= "Sender's Name: $_POST[sender_name]\n";

    $msg .= "Mailing Address:  $_POST[sender_address]\n";

    $msg .= "Phone Number:  $_POST[phone_number]\n";

    $msg .= "Are you a BREA Member?:    $_POST[radiogroup]\n";

    $msg .= "BREA Member Number:    $_POST[member_number]\n";

    $msg .= "Sender's E-Mail:  $_POST[sender_email]\n";

    $msg .= "Do you need a Membership Card?:    $_POST[radiogroup1]\n";

    $msg .= "What class?:  $_POST[class_date]\n";

    $msg .= "Comments:  $_POST[comments]\n";

 

    $to = "[email protected]";

    $subject = "Community Classes";

    $mailheaders = "From: $_POST[sender_email]\n";

    $mailheaders .= "Reply-To: $_POST[sender_email]\n\n";

    //send the mail  [email protected]

 

    mail($to, $subject, $msg, $mailheaders);

    //display confirmation to user

 

    echo "<div align=\"center\"><p><img src=\"../images/brea-logo.gif\"  height=\"78\" width=\"73\" align=\"center\" border=\"0\"></p><p>Your sign up is being processed.</p><p>If you do not recieve a confirmation email, please contact us by phone at (509) 786-4004.</p><p>We will contact you at the phone number given if we have further questions.</p><p>Thank you for your participation.</p><p><input type=\"button\" value=\"Back\" onClick=\"window.location.href=window.location.href\"></p></div>";

 

    }

else if ($send == "no"){

    //Print error messages

 

    echo "$name_err";

    echo "$address_err";

    echo "$phone_err";

    echo "$mem_err";

    echo "$memnum_err";

    echo "$email_err";

    echo "$class_err";

    echo "$comm_err";

    echo "$form_block";

    }

}

?>

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.