Jump to content
xisto Community
ginginca

Data Passing - Re An Assignment For School - Please Help :)

Recommended Posts

I'm working on a small assignment due tomorrow and am having some trouble.

 

I have a functioning form that you input the data on one php page, and then it does a little math and displays the result on a new page.

 

The assignment is to make this work on ONE page, and to add some error handling.

 

I'm having trouble with the basics of passing the data that has been input on the form, back to itself.

 

I am stuck with a few questions but I'll start with one.

 

I have the data passing back to itself so that when I start the error checking, the fields won't have to be repopulated.

 

Next I have to PROCESS the form, which previously had to go to a new php page. This one stays on the same page.

 

I don't know where to add my code from page two, onto page one, to make it one page.

 

Here is what I have to this point:

 

<?php/** * Student Assignment #2 * Order Form *  * @package Chapter7 *///Retrieve data//Post Action 	$action = (!empty($_POST['action'])) ? $_POST['action'] : "";//item 1	$item_1_purchased = (!empty($_POST['item_1_purchased'])) ? $_POST['item_1_purchased'] : "";			//item 1	$item_1_size = (!empty($_POST['item_1_size'])) ? $_POST['item_1_size'] : "";			//item 1	$item_1_qty = (!empty($_POST['item_1_qty'])) ? $_POST['item_1_qty'] : "";			//item 2	$item_2_purchased = (!empty($_POST['item_2_purchased'])) ? $_POST['item_2_purchased'] : "";			//item 2	$item_2_size = (!empty($_POST['item_2_size'])) ? $_POST['item_2_size'] : "";			//item 2	$item_2_qty = (!empty($_POST['item_2_qty'])) ? $_POST['item_2_qty'] : "";			//item 3	$item_3_purchased = (!empty($_POST['item_3_purchased'])) ? $_POST['item_3_purchased'] : "";			//item 3	$item_3_size = (!empty($_POST['item_3_size'])) ? $_POST['item_3_size'] : "";			//item 3	$item_3_qty = (!empty($_POST['item_3_qty'])) ? $_POST['item_3_qty'] : "";					//Check to see if the web page called itself	if (strtoupper($action) == "CHECK") {		//The web page called itself, so run the error checking code		//Declare a variable to hold the error messages		$err_msg = '';				}		?><html><head><meta http-equiv="Content-Language" content="en" /><meta name="GENERATOR" content="Zend Studio" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Order Form</title></head><body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99"><form id="MyOrder" action="<?php echo $_SEVRER['PHP_SELF']; ?>" method="POST"><input type="hidden" name="action" value="CHECK"/><table align ="center" cellpadding="1" cellspacing="1" width="550" border="0">	<tr>		<td colspan="5" height="50" align="center" valign="middle">		<font size="4" face="Arial, Helvetica, sans-serif"><B>Order Form</B></font><BR>		<font size="2" color="Red" face="Arial, Helvetica, sans-serif">Check off the products you wish to purchase.</font>		</td>	</tr>	<tr bgcolor="#CCCCCC">		<td align="center" valign="middle" width="50"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Select Items</B></font></td>		<td align="center" valign="middle" width="200"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Product Name</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Price</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Size</B><BR>(S, M, L or XL)</font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Qty</B></font></td>	</tr>	<tr bgcolor="#EEEEEE">		<input type="hidden" name="item_1_product" value="Zend Studio T-Shirt"/> 		<input type="hidden" name="item_1_price" value="14.45"/>  		<td align="center" valign="middle" width="50"><input type="checkbox" name="item_1_purchased" value="YES" <?php echo ($item_1_purchased =="YES") ?"checked" : ""; ?>/></td>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif">Zend Studio T-Shirt</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">$14.45</font></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_1_size" size="5" value="<?php echo $item_1_size; ?>"/></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_1_qty" size="5" value="<?php echo $item_1_qty; ?>"/></td>			</tr>	<tr>		<input type="hidden" name="item_2_product" value="Zend Studio Jacket"/>  		<input type="hidden" name="item_2_price" value="125.75"/>		<td align="center" valign="middle" width="50"><input type="checkbox" name="item_2_purchased" value="YES" <?php echo ($item_2_purchased =="YES") ?"checked" : ""; ?>/></td>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif">Zend Studio Jacket</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">$125.75</font></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_2_size" size="5" value="<?php echo $item_2_size; ?>"/></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_2_qty" size="5" value="<?php echo $item_2_qty; ?>"/></td>			</tr>	<tr bgcolor="#EEEEEE">		<input type="hidden" name="item_3_product" value="Zend Studio Mug"/>  		<input type="hidden" name="item_3_price" value="7.95"/>		<td align="center" valign="middle" width="50"><input type="checkbox" name="item_3_purchased" value="YES" <?php echo ($item_3_purchased =="YES") ?"checked" : ""; ?>/></td>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif">Zend Studio Mug</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">$7.95</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">N/A</font></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_3_qty" size="5" value="<?php echo $item_3_qty; ?>"/></td>			</tr>	<tr>		<td colspan="5" height="40" align="center" valign="middle">		<input type="submit" name="submit" value="Order Now!"/>  		</td>	</tr></table></form></body></html>

The 2nd page is one that totals the order and it currently works when I have these as two php pages.

Share this post


Link to post
Share on other sites

man i have to say you work in a really odd way!!i cant even read your script rightbut ill try to helptry to use isset and not in emptynow here is some tips for working in NONE ODD way lol - open and close bloks ( { } ) so the script will be readableuse new lines, and dont use Zend Studio lol- try what i said and tell me if the problom continue (isset and no empty)NoMore

Share this post


Link to post
Share on other sites

man i have to say you work in a really odd way!!


Critque all you want to!!!!

I'm learning.

Can you read this?

<?php/** * Student Assignment #2 * Order Form * @package Chapter7 *///Retrieve data//Post Action 	$action = (isset($_POST['action'])) ? $_POST['action'] : "";//item 1	$item_1_purchased = (isset($_POST['item_1_purchased'])) ? $_POST['item_1_purchased'] : "";			//item 1	$item_1_size = (isset($_POST['item_1_size'])) ? $_POST['item_1_size'] : "";			//item 1	$item_1_qty = (isset($_POST['item_1_qty'])) ? $_POST['item_1_qty'] : "";			//item 2	$item_2_purchased = (isset($_POST['item_2_purchased'])) ? $_POST['item_2_purchased'] : "";			//item 2	$item_2_size = (isset($_POST['item_2_size'])) ? $_POST['item_2_size'] : "";			//item 2	$item_2_qty = (isset($_POST['item_2_qty'])) ? $_POST['item_2_qty'] : "";			//item 3	$item_3_purchased = (isset($_POST['item_3_purchased'])) ? $_POST['item_3_purchased'] : "";			//item 3	$item_3_size = (isset($_POST['item_3_size'])) ? $_POST['item_3_size'] : "";			//item 3	$item_3_qty = (isset($_POST['item_3_qty'])) ? $_POST['item_3_qty'] : "";					//Check to see if the web page called itself	if (strtoupper($action) == "CHECK") {		//The web page called itself, so run the error checking code		//Declare a variable to hold the error messages		$err_msg = '';	}?>

Edited by ginginca (see edit history)

Share this post


Link to post
Share on other sites
if (isset($_POST($hidden_field)) {--- do this code block --- check for info accuracy, do math, etc} else {--- do this code block --- form submission instructions here}--- display form here ---<form blah, blah action="post"><input elements here><hidden input field name = "submitted" value="yes"></form>
Since it is a school assignment, I won't give you any more than this, but it should be sufficient to kick you off.
This is called a "redux" method, by the way. Single page that presents the form, accepts the data, does its error-checking, processes it and then presents the form again, with sticky data if some fields are missing or wrong, for correction and re-submit.
Good Luck..

Share this post


Link to post
Share on other sites

I see that your instructor is teaching you very pretty PHP dispite what others may think. The style of coding that you use is hard for some people to read which is why it isn't very common. I personally prefer to use the easy to read method for future debugging but this is very nice code that you have here. Please continue to use this more sophisticated style of scripting.You should place you data handling code from your second file in the conditional statement that checks to see if the page called itself. You don't need to worry about any of that stuff if the page wasn't called from itself so it shouldn't be used if the page is the blank form only!So I would place it in your curly braces right after $err_msg = '';.I hope this helps and I'll try to check back in on this topic for awhile.vujsa

Share this post


Link to post
Share on other sites

Don't be concerned about assisting me with an assignment. The instructor has no issues with that (even on our final exam) because in the real world when people have questions they go to forums and ask them.

I don't think I understand yet where my page two of the code goes. Here is what I have so far. Can you tell me if I have put it in the right place?

<?php/** * Student Assignment #2  *///Retrieve data//Post Action 	$action = (isset($_POST['action'])) ? $_POST['action'] : "";//item 1	$item_1_purchased = (isset($_POST['item_1_purchased'])) ? $_POST['item_1_purchased'] : "";			//item 1	$item_1_size = (isset($_POST['item_1_size'])) ? $_POST['item_1_size'] : "";			//item 1	$item_1_qty = (isset($_POST['item_1_qty'])) ? $_POST['item_1_qty'] : "";			//item 2	$item_2_purchased = (isset($_POST['item_2_purchased'])) ? $_POST['item_2_purchased'] : "";			//item 2	$item_2_size = (isset($_POST['item_2_size'])) ? $_POST['item_2_size'] : "";			//item 2	$item_2_qty = (isset($_POST['item_2_qty'])) ? $_POST['item_2_qty'] : "";			//item 3	$item_3_purchased = (isset($_POST['item_3_purchased'])) ? $_POST['item_3_purchased'] : "";			//item 3	$item_3_qty = (isset($_POST['item_3_qty'])) ? $_POST['item_3_qty'] : "";					//Check to see if the web page called itself	if (strtoupper($action) == "CHECK") {		//The web page called itself, so run the error checking code		//Declare a variable to hold the error messages		$err_msg = '';	}	else {<html><head><meta http-equiv="Content-Language" content="en" /><meta name="GENERATOR" content="Zend Studio" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Process Order</title></head><body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">	  		<table align ="center" cellpadding="3" cellspacing="1" width="550" border="0">	<tr>		<td colspan="5" height="50" align="center" valign="middle">		<font size="4" face="Arial, Helvetica, sans-serif"><B>Products Ordered</B></font><BR>				</td>	</tr>	<tr bgcolor="#CCCCCC">				<td align="center" valign="middle" width="200"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Product Name</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Price</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Size</B><BR>(S, M, L or XL)</font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Qty</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Subtotal</B></font></td>	</tr>	<tr bgcolor="#EEEEEE">		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_1_product; ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_1_price,2); ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_1_size; ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_1_qty; ?></font></td>				<td align="right" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_1_qty*$item_1_price,2);?></font></td>	</tr>	<tr>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_2_product; ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_2_price,2); ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_2_size; ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_2_qty; ?></font></td>				<td align="right" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_2_qty*$item_2_price,2);?></font></td>	</tr>	<tr bgcolor="#EEEEEE">		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_3_product; ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_3_price,2); ?></font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">N/A</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print $item_3_qty; ?></font></td>				<td align="right" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_3_qty*$item_3_price,2);?></font></td>			</tr>	<tr>		<td align="center" valign="middle" width="200"></td>		<td align="center" valign="middle" width="100"></td>		<td align="center" valign="middle" width="100"></td>		<td align="center" valign="middle" width="100"></td>				<td align="right" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif"><?php print '$' .number_format($item_1_qty*$item_1_price+$item_2_qty*$item_2_price+$item_3_qty*$item_3_price,2);?></font></td>			</tr>	</table>}						?><html><head><meta http-equiv="Content-Language" content="en" /><meta name="GENERATOR" content="Zend Studio" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Order Form</title></head><body onload="Init()" bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99"><form id="MyOrder" action="<?php echo $_SEVRER['PHP_SELF']; ?>" method="POST"><input type="hidden" name="action" value="CHECK"/><table align ="center" cellpadding="1" cellspacing="1" width="550" border="0">	<tr>		<td colspan="5" height="50" align="center" valign="middle">		<font size="4" face="Arial, Helvetica, sans-serif"><B>Order Form</B></font><BR>		<font size="2" color="Red" face="Arial, Helvetica, sans-serif">Check off the products you wish to purchase.</font>		</td>	</tr>	<tr bgcolor="#CCCCCC">		<td align="center" valign="middle" width="50"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Select Items</B></font></td>		<td align="center" valign="middle" width="200"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Product Name</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Price</B></font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Size</B><BR>(S, M, L or XL)</font></td>		<td align="center" valign="middle" width="100"><font size="2" color="Blue" face="Arial, Helvetica, sans-serif"><B>Qty</B></font></td>	</tr>	<tr bgcolor="#EEEEEE">		<input type="hidden" name="item_1_product" value="Zend Studio T-Shirt"/> 		<input type="hidden" name="item_1_price" value="14.45"/>  		<td align="center" valign="middle" width="50"><input type="checkbox" name="item_1_purchased" value="YES" <?php echo ($item_1_purchased =="YES") ?"checked" : ""; ?>/></td>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif">Zend Studio T-Shirt</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">$14.45</font></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_1_size" size="5" value="<?php echo $item_1_size; ?>"/></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_1_qty" size="5" value="<?php echo $item_1_qty; ?>"/></td>			</tr>	<tr>		<input type="hidden" name="item_2_product" value="Zend Studio Jacket"/>  		<input type="hidden" name="item_2_price" value="125.75"/>		<td align="center" valign="middle" width="50"><input type="checkbox" name="item_2_purchased" value="YES" <?php echo ($item_2_purchased =="YES") ?"checked" : ""; ?>/></td>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif">Zend Studio Jacket</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">$125.75</font></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_2_size" size="5" value="<?php echo $item_2_size; ?>"/></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_2_qty" size="5" value="<?php echo $item_2_qty; ?>"/></td>			</tr>	<tr bgcolor="#EEEEEE">		<input type="hidden" name="item_3_product" value="Zend Studio Mug"/>  		<input type="hidden" name="item_3_price" value="7.95"/>		<td align="center" valign="middle" width="50"><input type="checkbox" name="item_3_purchased" value="YES" <?php echo ($item_3_purchased =="YES") ?"checked" : ""; ?>/></td>		<td align="center" valign="middle" width="200"><font size="2" face="Arial, Helvetica, sans-serif">Zend Studio Mug</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">$7.95</font></td>		<td align="center" valign="middle" width="100"><font size="2" face="Arial, Helvetica, sans-serif">N/A</font></td>		<td align="center" valign="middle" width="100"><input type="text" name="item_3_qty" size="5" value="<?php echo $item_3_qty; ?>"/></td>			</tr>	<tr>		<td colspan="5" height="40" align="center" valign="middle">		<input type="submit" name="submit" value="Order Now!"/>  		</td>	</tr></table></form></body></html>

Share this post


Link to post
Share on other sites

Sorry for the long absense, been offering support for a couple of scripts which was rather time consuming.

 

Hope I have the stamina to get through this bit of code!

 

What I'll do here is write three sample scripts: Page1.php, page2.php and page1and2.php!

 

page1.php:

<html>	<head>		<title>			Sample Page1.php Script		</title>		<meta name="description" content="PHP Assignment">		<meta name="keywords" content="PHP">		<meta name="author" content="vujsa">	</head>	<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">		<form action="page2.php" method="post">			<input type="text" name="text1" size="30" value="<?php echo "Test 1"; ?>"><br />			<input type="text" name="text2" size="30" value="<?php echo "Test 2"; ?>"><br />			<input type="submit" name="submit" value="submit"><br />		</form>	</body></html>

page2.php:

<?php if (isset($_POST['text1'])){	$text1 = $_POST['text1'];}else{	$text1 = "";}if (isset($_POST['text2'])){	$text2 = $_POST['text2'];}else{	$text2 = "";}$output = "You typed : "$text1 . " " . $text2 . "<br />\n>;?><html>	<head>		<title>			Sample Page2.php Script		</title>		<meta name="description" content="PHP Assignment">		<meta name="keywords" content="PHP">		<meta name="author" content="vujsa">	</head>	<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">		<form action="page2.php" method="post">			<input type="text" name="text1" size="30" value="<?php echo $text1; ?>"><br />			<input type="text" name="text2" size="30" value="<?php echo $text2; ?>"><br />			<input type="submit" name="submit" value="submit"><br />		</form><br /><?php echo $output; ?>	</body></html>

So to combine those two is rather easy actually. Since they are so similar to begin with.

 

page1and2.php:

<?php if($_POST['submitted'] == "yes"){ // Do the following if the script was requested by itself!	if (isset($_POST['text1'])){		$text1 = $_POST['text1'];	}	else{		$text1 = "";	}		if (isset($_POST['text2'])){		$text2 = $_POST['text2'];	}	else{		$text2 = "";	}	$output = "You typed : " . $text1 . " " . $text2 . "<br />\n";}else{ // Do the following if the script was NOT requested by itself!	$text1 = "Test 1";	$text2 = "Test 2";	$output = "";}?><html>	<head>		<title>			Sample Page1and2.php Script		</title>		<meta name="description" content="PHP Assignment">		<meta name="keywords" content="PHP">		<meta name="author" content="vujsa">	</head>	<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">		<form action="page2.php" method="post">			<input type="hidden" name="submitted" value="yes>">			<input type="text" name="text1" size="30" value="<?php echo $text1; ?>"><br />			<input type="text" name="text2" size="30" value="<?php echo $text2; ?>"><br />			<input type="submit" name="submit" value="submit"><br />		</form><br /><?php echo $output; ?>	</body></html>

You should recycle as much of the HTML as possible to cut down on the size of the script which will make it easier to manage. Then, use inline PHP tags to fill in the dynamic parts of the HTML like the <?php echo $text1; ?>. The Main PHP does whatever functions that your second page would have done plus it now checks to see if the request was from the submitted form or if this is a new page load altogether. If it is a new page load, display the blank form or a form with default values prefilled. If the request was from the form being submitted, display the form with the new values inserted and at the bottom display whatever it is that the script is supposed to process! Here is an additional consideration:

 

Only display the submit button if the form is blank!

page1and2.php (optional):

<?php if($_POST['submitted'] == "yes"){ // Do the following if the script was requested by itself!	if (isset($_POST['text1'])){		$text1 = $_POST['text1'];	}	else{		$text1 = "";	}		if (isset($_POST['text2'])){		$text2 = $_POST['text2'];	}	else{		$text2 = "";	}	$output = "You typed : " . $text1 . " " . $text2 . "<br />\n";	$submit = "";}else{ // Do the following if the script was NOT requested by itself!	$text1 = "Test 1";	$text2 = "Test 2";	$output = "";	$submit = "<input type=\"submit\" name=\"submit\" value=\"submit\"><br />";}?><html>	<head>		<title>			Sample Page1and2.php Script		</title>		<meta name="description" content="PHP Assignment">		<meta name="keywords" content="PHP">		<meta name="author" content="vujsa">	</head>	<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">		<form action="page2.php" method="post">			<input type="hidden" name="submitted" value="yes>">			<input type="text" name="text1" size="30" value="<?php echo $text1; ?>"><br />			<input type="text" name="text2" size="30" value="<?php echo $text2; ?>"><br />			<?php echo $submit; ?>		</form><br /><?php echo $output; ?>	</body></html>

In addition to this, you could even display the submit button after the form is submitted if a field was left blank so the user could fill in the blank field and resubmit! Highlighting or off color text could also be used for blank fields.

 

I hope that this has provided you with enough of a sample to get your script finished. I tried to offer as many options as possible in a small space. From this I think you can determin which parts to make static and which to make dynamic.

 

If you need more assistance, let me know.

 

vujsa

Share this post


Link to post
Share on other sites

Well the good news, is I was trying to go too far with this project. It was the NEXT phase to turn it into one page.

I copied your code to my hard drive and gave it a whirl, but I ended up with an error message. (Sorry).

But my project has progressed nontheless and I have made some steps forward.

Here's my question today.

My structure is

(1) customer places an order

(2) php checks for errors

(3) php displays the order once there's no errors

All from one page.

Right now, I have one page ... but when I place the order, the original order still stays on the screen. It doesn't go away ... likley something with my IF statement to see if the page has called itself.

When you hit the submit button, the order just draws itself UNDER what I already had.

The code is here:

http://www.londonlink.ca/order_form.phps

Comments, guidance and criticism please?

(but be gentle ... I'm still new to this).

*grin*

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.