Jump to content

Recommended Posts

Hello everyone. I am writing this order/feedback form using a php script.

Every time i hit submit, the html page (that has the form inside) just reloads and does not perform the script 

could anyone give me some pointers in my code the form/php?

I have made sure they are linked verbatim

I am a nube so please forgive my inexperience

 

Here is the form in the html , down below it is the corresponding php code for the form

 

 
<form action="send_mail.php" method="post">
 
<table align="left">
 
<tr>
      <td> <input type="checkbox" name="food1" value="" />
        1 Fudge Brownie</td>
      <td><input style="color:#000000" type="number" name="onefudgebrownie" /> </td>
     </tr>
 
 
<tr>
      <td> <input type="checkbox" name="food2" value="" />
       4 Italian Biscotti </td>
      <td><input style="color:#000000" type="number" name="fouritalianbiscotti" /> </td>
     </tr>
 
    
 
<tr>
      <td> <input type="checkbox" name="food3" value="" />
       4 Soft & Chewy Chocolate Chip Cookies</td>
      <td><input style="color:#000000" type="number" name="foursoftchewychocolatechipcookies" /> </td>
     </tr>
 
<tr>
      <td> <input type="checkbox" name="food4" value="" />
        4 Cape Cod Cranberry Oatmeal Cookies</td>
      <td><input style="color:#000000" type="number" name="fourcapecodcranberryoatmealcookies" /> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food5" value="" />
       1 Loaf of Artisan French Bread.              </td>
      <td><input style="color:#000000" type="number" name="oneloafofartisanfrenchbread" /> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food6" value="" />
       6 Kaiser Deli Rolls </td>
      <td><input style="color:#000000" type="number" name="sixkaiserdelirolls" /> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food7" value="" />
      6 Soft Hamburger Rolls</td>
      <td><input style="color:#000000" type="number" name="sixsofthamburgerrolls"/> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food8" value=""/> 
      6 5 sub rolls</td>
      <td><input style="color:#000000" type="number" name="sixfiveinchsubrolls"/> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food9" value="" />
      12 2" slider rolls</td>
      <td><input style="color:#000000" type="number" name="twelvetwoinchsliderrolls"/> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food10" value="" />
        4 Snickerdoodle Cookies</td>
      <td><input style="color:#000000" type="number" name="foursnkickerdoodlecookies"/> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food11" value="" />
      1 Colossal Cinnamon Sticky Bun</td>
      <td><input style="color:#000000" type="number" name="onecolossalcinnamonstickybun"/> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food12" value="" />
       1 Delicious Whoopie Pie</td>
      <td><input style="color:#000000" type="number" name="onedeliciouswhoopiepie"/> </td>
    </tr>
 
<tr>
      <td> <input type="checkbox" name="food13" value="" />
      4 island coconut macaroons</td>
      <td><input style="color:#000000" type="number" name="fourislandcoconutmacaroons"/> </td>
    </tr>
 
<tr>
<td>Comments/Special Requests:</td>
<td>
<textarea rows="10" cols="50" name="comments" style="color:#000000"  ></textarea>
</td>
</tr>
 
 
 
</table>
 
<br></br>
 
<!--Shipping info/Personal Info Table -->
 
<h3 align="left"> Shipping Information </h3>
 
<table align="left">
 
 
<tr>
<td>Last Name:</td>
<td>
<input style="color:#000000" type="text" name="shippinglastname" value="" maxlength="15" />
</td>
 
 
<td>First Name:</td>
<td>
<input style="color:#000000" type="text" name="shippingfirstname" value="" maxlength="10" />
</td>
</tr>
 
 
<td>Telephone/Cell.:</td>
<td>
<input style="color:#000000"  type="text" name="telephonecell" value="" maxlength="100" />
</td>
 
 
 
<td>Email Address:</td>
<td>
<input style="color:#000000"  type="text" name="emailaddress" value="" maxlength="100" />
</td>
</tr>
 
 
<tr>
<td>Brief description of location on the lake:</td>
<td>
<textarea rows="10" cols="50" name="breifdescript" style="color:#000000">    </textarea>
</td>
</tr>
 
 
 
 
<!--SUBMIT BUTTON -->
 
<tr>
    <td> </td>
<td>
<input type="submit" value="Submit" 
style=
    background-color:#87D163;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius:6px;
    color: #fff;
    font-family: 'Oswald';
    font-size: 20px;
    text-decoration: none;
    cursor: pointer;
    border:none;
 
 
submit:hover {
 
    border: none;
    background:#000000;
    box-shadow: 0px 0px 1px #777;
}"
/>
</td>
</tr>
 
<!--SUBMIT BUTTON end -->
 
</table>
 
</form>
 
PHP code below;
 
<?php
/*SET THIS RIGHT BELOW AS THE FORM RECIEVING EMAIL*/
 
$webmaster_email = "__________@gmail.com";
 
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
 
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
 
 
/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
*/
 
/* First section of variables are for the Items/Food */
$food1 = $_REQUEST['food1'] ;
 
$onefudgebrownie = $_REQUEST['onefudgebrownie'] ;
 
$food2 = $_REQUEST['food2'] ;
 
$fouritalianbiscotti = $_REQUEST['fouritalianbiscotti'] ;
 
$food3 = $_REQUEST['food3'] ;
 
$foursoftchewychocolatechipcookies = $_REQUEST['foursoftchewychocolatechipcookies'] ;
 
$food4 = $_REQUEST['food4'] ;
 
$fourcapecodcranberryoatmealcookies = $_REQUEST['fourcapecodcranberryoatmealcookies'] ;
 
$food5 = $_REQUEST['food5'] ;
 
$oneloafofartisanfrenchbread = $_REQUEST['oneloafofartisanfrenchbread'] ;
 
$food6 = $_REQUEST['food6'] ;
 
$sixkaiserdelirolls = $_REQUEST['sixkaiserdelirolls'] ;
 
$food7 = $_REQUEST['food7'] ;
 
$sixsofthamburgerrolls = $_REQUEST['sixsofthamburgerrolls'] ;
 
$food8 = $_REQUEST['food8'] ;
 
$sixfiveinchsubrolls = $_REQUEST['sixfiveinchsubrolls'] ;
 
$food9 = $_REQUEST['food9'] ;
 
$twelvetwoinchsliderrolls = $_REQUEST['twelvetwoinchsliderrolls'] ;
 
$food10 = $_REQUEST['food10'] ;
 
$foursnkickerdoodlecookies = $_REQUEST['foursnkickerdoodlecookies'] ;
 
$food11 = $_REQUEST['food11'] ;
 
$onecolossalcinnamonstickybun = $_REQUEST['onecolossalcinnamonstickybun'] ;
 
$food12 = $_REQUEST['food12'] ;
 
$onedeliciouswhoopiepie = $_REQUEST['onedeliciouswhoopiepie'] ;
 
$food13 = $_REQUEST['food13'] ;
 
$fourislandcoconutmacaroons = $_REQUEST['fourislandcoconutmacaroons'] ;
 
/* This second section of variables are for the Shipping/Customer Info*/
 
$shippinglastname = $_REQUEST['shippinglastname'] ;
 
$shippingfirstname = $_REQUEST['shippingfirstname'] ;
 
$telephonecell = $_REQUEST['telephonecell'] ;
 
$emailaddress = $_REQUEST['emailaddress'] ;
 
$breifdescript = $_REQUEST['breifdescript'] ;
 
 
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
 
// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}
 
// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}
 
// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}
 
// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( "$webmaster_email", "Feedback Form Results",
  $comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>
 
 
 

dessertsondemandorderform.html

Link to comment
https://forums.phpfreaks.com/topic/289016-php-form-redirects-back-to-html-page/
Share on other sites

Actually I don't think it is re-directing. Your script starts off with all your html being output before it does any php. You can't execute a header command at that point.

 

Turn on php error checking and do your php before you send any html output. See what you get then.

Actually your code is kind of a mess. You don't do any checking to see if any of your inputs are set. You don't validate or sanitize them. and you don't handle the errors that will arise from your script as it is now written.

 

I've taken the liberty to re-arrange your code and to structure it a little bit to make the whole thing a bit easier to comprehend. I added error checking (ALWAYS TURN IT ON!!!) so you can see the problems you have.

 

NOTE HOW I HAVE ALSO POSTED THIS CODE USING THE FORUM-MANDATED CODING TAGS. PLEASE USE THEM NEXT TIME.

<?
/*
*
*
*/
//***********************
error_reporting(E_ALL | E_STRICT | E_NOTICE);
ini_set('display_errors', '1');
/*SET THIS RIGHT BELOW AS THE FORM RECIEVING EMAIL*/
$webmaster_email = "__________@gmail.com";
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
//*****************
//  Begin
//*****************
//*****************
//
if (!isset($_POST['btn']))
{
	DisplayPage();
	exit();
}
if ($_POST['btn'] == 'Submit')
{
	/*
	This next bit loads the form field data into variables.
	If you add a form field, you will need to add it here.
	*/
	/* First section of variables are for the Items/Food */
	$food1 = $_POST['food1'] ;
	$onefudgebrownie = $_POST['onefudgebrownie'] ;
	$food2 = $_POST['food2'] ;
	$fouritalianbiscotti = $_POST['fouritalianbiscotti'] ;
	$food3 = $_POST['food3'] ;
	$foursoftchewychocolatechipcookies = $_POST['foursoftchewychocolatechipcookies'] ;
	$food4 = $_POST['food4'] ;
	$fourcapecodcranberryoatmealcookies = $_POST['fourcapecodcranberryoatmealcookies'];
	$food5 = $_POST['food5'] ;
	$oneloafofartisanfrenchbread = $_POST['oneloafofartisanfrenchbread'] ;
	$food6 = $_POST['food6'] ;
	$sixkaiserdelirolls = $_POST['sixkaiserdelirolls'] ;
	$food7 = $_POST['food7'] ;
	$sixsofthamburgerrolls = $_POST['sixsofthamburgerrolls'] ;
	$food8 = $_POST['food8'] ;
	$sixfiveinchsubrolls = $_POST['sixfiveinchsubrolls'] ;
	$food9 = $_POST['food9'] ;
	$twelvetwoinchsliderrolls = $_POST['twelvetwoinchsliderrolls'] ;
	$food10 = $_POST['food10'] ;
	$foursnkickerdoodlecookies = $_POST['foursnkickerdoodlecookies'] ;
	$food11 = $_POST['food11'] ;
	$onecolossalcinnamonstickybun = $_POST['onecolossalcinnamonstickybun'] ;
	$food12 = $_POST['food12'] ;
	$onedeliciouswhoopiepie = $_POST['onedeliciouswhoopiepie'] ;
	$food13 = $_POST['food13'] ;
	$fourislandcoconutmacaroons = $_POST['fourislandcoconutmacaroons'] ;
	/* This second section of variables are for the Shipping/Customer Info*/
	$shippinglastname = $_POST['shippinglastname'] ;
	$shippingfirstname = $_POST['shippingfirstname'] ;
	$telephonecell = $_POST['telephonecell'] ;
	$emailaddress = $_POST['emailaddress'] ;
	$breifdescript = $_POST['breifdescript'] ;
	// If the user tries to access this script directly, redirect them to the feedback form,
	if (!isset($_POST['email_address']))
	{
		header( "Location: $feedback_page" );
	}
	// If the form fields are empty, redirect to the error page.
	elseif (empty($email_address) || empty($comments))
	{
		header( "Location: $error_page" );
	}
	// If email injection is detected, redirect to the error page.
	elseif ( isInjected($email_address) )
	{
		header( "Location: $error_page" );
	}
	// If we passed all previous tests, send the email then redirect to the thank you page.
	else
	{
		mail( "$webmaster_email", "Feedback Form Results",$comments, "From: $email_address" );
		header( "Location: $thankyou_page" );
	}
}
//******************
echo "Unhandled button ";
exit();
//******************
//******************
//******************
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str)
{
	$injections = array('(\n+)','(\r+)','(\t+)','(%0A+)',
		'(%0D+)','(%08+)','(%09+)');
	$inject = join('|', $injections);
	$inject = "/$inject/i";
	if(preg_match($inject,$str))
	{
		return true;
	}
	else
	{
		return false;
	}
}
function DisplayPage()
{
	$code=<<<heredocs
	<form action="send_mail.php" method="post">
	<table align="left">
	<tr>
	<td> <input type="checkbox" name="food1" value="" />
	1 Fudge Brownie</td>
	<td><input style="color:#000000" type="number" name="onefudgebrownie" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food2" value="" />
	4 Italian Biscotti </td>
	<td><input style="color:#000000" type="number" name="fouritalianbiscotti" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food3" value="" />
	4 Soft & Chewy Chocolate Chip Cookies</td>
	<td><input style="color:#000000" type="number" name="foursoftchewychocolatechipcookies" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food4" value="" />
	4 Cape Cod Cranberry Oatmeal Cookies</td>
	<td><input style="color:#000000" type="number" name="fourcapecodcranberryoatmealcookies" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food5" value="" />
	1 Loaf of Artisan French Bread.              </td>
	<td><input style="color:#000000" type="number" name="oneloafofartisanfrenchbread" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food6" value="" />
	6 Kaiser Deli Rolls </td>
	<td><input style="color:#000000" type="number" name="sixkaiserdelirolls" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food7" value="" />
	6 Soft Hamburger Rolls</td>
	<td><input style="color:#000000" type="number" name="sixsofthamburgerrolls"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food8" value=""/>
	6 5 sub rolls</td>
	<td><input style="color:#000000" type="number" name="sixfiveinchsubrolls"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food9" value="" />
	12 2" slider rolls</td>
	<td><input style="color:#000000" type="number" name="twelvetwoinchsliderrolls"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food10" value="" />
	4 Snickerdoodle Cookies</td>
	<td><input style="color:#000000" type="number" name="foursnkickerdoodlecookies"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food11" value="" />
	1 Colossal Cinnamon Sticky Bun</td>
	<td><input style="color:#000000" type="number" name="onecolossalcinnamonstickybun"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food12" value="" />
	1 Delicious Whoopie Pie</td>
	<td><input style="color:#000000" type="number" name="onedeliciouswhoopiepie"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food13" value="" />
	4 island coconut macaroons</td>
	<td><input style="color:#000000" type="number" name="fourislandcoconutmacaroons"/> </td>
	</tr>
	<tr>
	<td>Comments/Special Requests:</td>
	<td>
	<textarea rows="10" cols="50" name="comments" style="color:#000000"  ></textarea>
	</td>
	</tr>
	</table>
	<br></br>
	<!--Shipping info/Personal Info Table -->
	<h3 align="left"> Shipping Information </h3>
	<table align="left">
	<tr>
	<td>Last Name:</td>
	<td>
	<input style="color:#000000" type="text" name="shippinglastname" value="" maxlength="15" />
	</td>
	<td>First Name:</td>
	<td>
	<input style="color:#000000" type="text" name="shippingfirstname" value="" maxlength="10" />
	</td>
	</tr>
	<td>Telephone/Cell.:</td>
	<td>
	<input style="color:#000000"  type="text" name="telephonecell" value="" maxlength="100" />
	</td>
	<td>Email Address:</td>
	<td>
	<input style="color:#000000"  type="text" name="emailaddress" value="" maxlength="100" />
	</td>
	</tr>
	<tr>
	<td>Brief description of location on the lake:</td>
	<td>
	<textarea rows="10" cols="50" name="breifdescript" style="color:#000000">    </textarea>
	</td>
	</tr>
	<!--SUBMIT BUTTON -->
	<tr>
	<td> </td>
	<td>
	<input type="submit" name='btn'value="Submit"
	style =	"
	background-color:#87D163;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius:6px;
	color: #fff;
	font-family: 'Oswald';
	font-size: 20px;
	text-decoration: none;
	cursor: pointer;
	border:none;
	submit:hover {
	border: none;
	background:#000000;
	box-shadow: 0px 0px 1px #777;
	}"	/>
	</td>
	</tr>
	<!--SUBMIT BUTTON end -->
	</table>
	</form>
heredocs;
	echo $code;
	return;
}
I also changed your code to use $_POST instead of request. Request is not recommended.

Try running this and see what happens.

Hello, thank you so much for your help
 
after i put it all in the page, i set the form action to it self, and change the feedback page also to its self
 
but when i hit submit it seems to not do anything

 

is there a problem with the form action= ?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <title>Desserts on Demand|Summer Cartering</title>

        <link rel="stylesheet" type="text/css" href="bootstrap.css" >
        <link rel="stylesheet" type="text/css" href="dessertsondemand.css">
		
		
        <meta name="description" content="Desserts on Demand">
        <meta name="description" content="Barrington">
        <meta name="description" content="New Hampshire Catering">
        <meta name="description" content="Pat briduea">
        <meta name="description" content="Skylight Dining Room">
        <meta name="keywords" content="Pat Briduea  ">
        <meta name="author" content="Pat Briduea">
        <meta charset="UTF-8">

    </head>
	<style>


#content
{
font-size:15px
height:100px;
overflow:scroll;
}

 /*   FORM BUTTON       */

}
#submit {
    background-color: #;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius:6px;
    color: #fff;
    font-family: 'Oswald';
    font-size: 20px;
    text-decoration: none;
    cursor: pointer;
    border:none;
}

#submit:hover {
    border: none;
    background:#000000;
    box-shadow: 0px 0px 1px #777;
}
	  
	  
	  
    </style> 
	<center>
    <body>
      
        <div id="container" style="width:900px;vertical-align: middle;">

           



			<center>
             <div id="header" style="background-color:#ffffff;
				border:1px solid white;
				border-top-left-radius:7px;
				border-top-right-radius:7px;
				height: 192px;
				margin-top: 8px;		
				margin-bottom: 8px;">
                <center><h1> 
                    <img src="logo.PNG" width="197" height="167" alt="" longdesc="file://///storage/graduates2015/christopher.harrigan/My Documents/e biss/dessertsondemand/dessertsondemandlogo.jpg" /> 
                </h1>
				</center>
            </div>
			







            <div id="menu" style="background-color:#ffffff;height:789px;width:225px;float:left;">
             
                <!-- buttons -->
         <br></br>
		 
         
             <button style="width:170px;height:35px;background-color:#87D163;"
             
             type="button" 
             class="btn btn-default">
             <a href="dessertsondemandhomepage.html"> Home </a>
             </button> 

         <br></br>

         <br></br>

             <button style="width:170px;height:35px;background-color:#87D163;"
             
             type="button" 
             class="btn btn-default">
             <a href="dessertsondemandmenupage.html"> Our Food </a>
             </button> 

         <br></br>
		 
		 <br></br>
             
             <button style="width:170px;height:35px;background-color:#87D163;"
             
             type="button" 
             class="btn btn-default">
             <a href="dessertsondemandorderform.html"> Order Form</a>
             </button> 
             </a> 
         <br></br> 
		 
		 <br></br> 
             <button style="width:170px;height:35px;background-color:#87D163;"
             
             type="button" 
             class="btn btn-default">
             <a href="dessertsondemandcontactus.html"> Contact Us </a>
             </button> 

        <br></br>
		 
            </div>

           




            <div id="content" style="background-color:#ffffff ;height:789px;width:675px;float:left;">
                <br></br>
				<center>
			    <h1> Desserts On Demand </h1>
				<h3> Summer Catering Made Fun! </h3> <br></br>
				</center>
				<!--This is the start of the order form-->
				<h2>Order Form</h2>
				<h4>Send Us Your Order!</h4>
	
<!-- form-->
	<h3 align="left"> Items/ food </h3>
	
	<?
*
*
*/
//***********************
error_reporting(E_ALL | E_STRICT | E_NOTICE);
ini_set('display_errors', '1');
/*SET THIS RIGHT BELOW AS THE FORM RECIEVING EMAIL*/
$webmaster_email = "-----------@gmail.com";
/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "dessertsondemandorderform.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";
//*****************
//  Begin
//*****************
//*****************
//
if (!isset($_POST['btn']))
{
	DisplayPage();
	exit();
}
if ($_POST['btn'] == 'Submit')
{
	/*
	This next bit loads the form field data into variables.
	If you add a form field, you will need to add it here.
	*/
	/* First section of variables are for the Items/Food */
	$food1 = $_POST['food1'] ;
	$onefudgebrownie = $_POST['onefudgebrownie'] ;
	$food2 = $_POST['food2'] ;
	$fouritalianbiscotti = $_POST['fouritalianbiscotti'] ;
	$food3 = $_POST['food3'] ;
	$foursoftchewychocolatechipcookies = $_POST['foursoftchewychocolatechipcookies'] ;
	$food4 = $_POST['food4'] ;
	$fourcapecodcranberryoatmealcookies = $_POST['fourcapecodcranberryoatmealcookies'];
	$food5 = $_POST['food5'] ;
	$oneloafofartisanfrenchbread = $_POST['oneloafofartisanfrenchbread'] ;
	$food6 = $_POST['food6'] ;
	$sixkaiserdelirolls = $_POST['sixkaiserdelirolls'] ;
	$food7 = $_POST['food7'] ;
	$sixsofthamburgerrolls = $_POST['sixsofthamburgerrolls'] ;
	$food8 = $_POST['food8'] ;
	$sixfiveinchsubrolls = $_POST['sixfiveinchsubrolls'] ;
	$food9 = $_POST['food9'] ;
	$twelvetwoinchsliderrolls = $_POST['twelvetwoinchsliderrolls'] ;
	$food10 = $_POST['food10'] ;
	$foursnkickerdoodlecookies = $_POST['foursnkickerdoodlecookies'] ;
	$food11 = $_POST['food11'] ;
	$onecolossalcinnamonstickybun = $_POST['onecolossalcinnamonstickybun'] ;
	$food12 = $_POST['food12'] ;
	$onedeliciouswhoopiepie = $_POST['onedeliciouswhoopiepie'] ;
	$food13 = $_POST['food13'] ;
	$fourislandcoconutmacaroons = $_POST['fourislandcoconutmacaroons'] ;
	/* This second section of variables are for the Shipping/Customer Info*/
	$shippinglastname = $_POST['shippinglastname'] ;
	$shippingfirstname = $_POST['shippingfirstname'] ;
	$telephonecell = $_POST['telephonecell'] ;
	$emailaddress = $_POST['emailaddress'] ;
	$breifdescript = $_POST['breifdescript'] ;
	// If the user tries to access this script directly, redirect them to the feedback form,
	if (!isset($_POST['email_address']))
	{
		header( "Location: $dessertsondemand.html" );
	}
	// If the form fields are empty, redirect to the error page.
	elseif (empty($email_address) || empty($comments))
	{
		header( "Location: $error_page" );
	}
	// If email injection is detected, redirect to the error page.
	elseif ( isInjected($email_address) )
	{
		header( "Location: $error_page" );
	}
	// If we passed all previous tests, send the email then redirect to the thank you page.
	else
	{
		mail( "$webmaster_email", "Feedback Form Results",$comments, "From: $email_address" );
		header( "Location: $thankyou_page" );
	}
}
//******************
echo "Unhandled button ";
exit();
//******************
//******************
//******************
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str)
{
	$injections = array('(\n+)','(\r+)','(\t+)','(%0A+)',
		'(%0D+)','(%08+)','(%09+)');
	$inject = join('|', $injections);
	$inject = "/$inject/i";
	if(preg_match($inject,$str))
	{
		return true;
	}
	else
	{
		return false;
	}
}
function DisplayPage()
{
	$code=<<<heredocs
	
	<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
	<table align="left">
	<tr>
	<td> <input type="checkbox" name="food1" value="" />
	1 Fudge Brownie</td>
	<td><input style="color:#000000" type="number" name="onefudgebrownie" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food2" value="" />
	4 Italian Biscotti </td>
	<td><input style="color:#000000" type="number" name="fouritalianbiscotti" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food3" value="" />
	4 Soft & Chewy Chocolate Chip Cookies</td>
	<td><input style="color:#000000" type="number" name="foursoftchewychocolatechipcookies" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food4" value="" />
	4 Cape Cod Cranberry Oatmeal Cookies</td>
	<td><input style="color:#000000" type="number" name="fourcapecodcranberryoatmealcookies" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food5" value="" />
	1 Loaf of Artisan French Bread.              </td>
	<td><input style="color:#000000" type="number" name="oneloafofartisanfrenchbread" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food6" value="" />
	6 Kaiser Deli Rolls </td>
	<td><input style="color:#000000" type="number" name="sixkaiserdelirolls" /> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food7" value="" />
	6 Soft Hamburger Rolls</td>
	<td><input style="color:#000000" type="number" name="sixsofthamburgerrolls"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food8" value=""/>
	6 5 sub rolls</td>
	<td><input style="color:#000000" type="number" name="sixfiveinchsubrolls"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food9" value="" />
	12 2" slider rolls</td>
	<td><input style="color:#000000" type="number" name="twelvetwoinchsliderrolls"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food10" value="" />
	4 Snickerdoodle Cookies</td>
	<td><input style="color:#000000" type="number" name="foursnkickerdoodlecookies"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food11" value="" />
	1 Colossal Cinnamon Sticky Bun</td>
	<td><input style="color:#000000" type="number" name="onecolossalcinnamonstickybun"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food12" value="" />
	1 Delicious Whoopie Pie</td>
	<td><input style="color:#000000" type="number" name="onedeliciouswhoopiepie"/> </td>
	</tr>
	<tr>
	<td> <input type="checkbox" name="food13" value="" />
	4 island coconut macaroons</td>
	<td><input style="color:#000000" type="number" name="fourislandcoconutmacaroons"/> </td>
	</tr>
	<tr>
	<td>Comments/Special Requests:</td>
	<td>
	<textarea rows="10" cols="50" name="comments" style="color:#000000"  ></textarea>
	</td>
	</tr>
	</table>
	<br></br>
	<!--Shipping info/Personal Info Table -->
	<h3 align="left"> Shipping Information </h3>
	<table align="left">
	<tr>
	<td>Last Name:</td>
	<td>
	<input style="color:#000000" type="text" name="shippinglastname" value="" maxlength="15" />
	</td>
	<td>First Name:</td>
	<td>
	<input style="color:#000000" type="text" name="shippingfirstname" value="" maxlength="10" />
	</td>
	</tr>
	<td>Telephone/Cell.:</td>
	<td>
	<input style="color:#000000"  type="text" name="telephonecell" value="" maxlength="100" />
	</td>
	<td>Email Address:</td>
	<td>
	<input style="color:#000000"  type="text" name="emailaddress" value="" maxlength="100" />
	</td>
	</tr>
	<tr>
	<td>Brief description of location on the lake:</td>
	<td>
	<textarea rows="10" cols="50" name="breifdescript" style="color:#000000">    </textarea>
	</td>
	</tr>
	<!--SUBMIT BUTTON -->
	<tr>
	<td> </td>
	<td>
	<input type="submit" name='btn'value="Submit"
	
	style =	"
	background-color:#87D163;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius:6px;
	color: #fff;
	font-family: 'Oswald';
	font-size: 20px;
	text-decoration: none;
	cursor: pointer;
	border:none;
	submit:hover {
	border: none;
	background:#000000;
	box-shadow: 0px 0px 1px #777;
	}"	/>
	
	</td>
	</tr>
	<!--SUBMIT BUTTON end -->
	</table>
	</form>

heredocs;
	echo $code;
	return;
}
            </div>

              <div id="footer" style="background-color:#fdfdfd;height:125px;clear:both;text-align:center-left;">     
                     <center>
					 <p style="font-size:6px;">
                     <h4> Contact Us </h4>

                     <strong>Address:</strong> Patrick & Maureen Brideau<br>
                     126 Pond Hill Rd,
                     Barrington, NH 03825<br>

                      <strong>Telephone:</strong> (603)-978-0417<br>
                      <strong>E-mail:</strong>  dessertsondemand1@gmail.com  </p>  </div>
					</center>
             </div>
      


    </body>
	</center>
 

</html>
Edited by chrisharrigan426

You buried a php tag inside the heredocs. I'm curious how that works. Try putting an echo statement right after line 324 to see if you are getting to that point when the script is run the FIRST time (when it has to display the screen for the first time).

 

PS - since you have buried all of my code inside a much larger script, try moving my error checking up to the beginning of your bigger script to catch any and all errors.

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.