Page 1 of 1

POST and GET not passing info?

Posted: Fri Apr 15, 2005 9:26 am
by dmacman1962
Hi All,

I have a php form and php process page that I am using and I cannot tell if I wrote the code wrong, or my php is not working correctly, but I cannot get the POST info from the form.

Here is the full code for the order page:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="process.php" method="post" name="SignOrder" id="SignOrder">
<?
$hostname = "localhost";
		$database = "a";
		$username = "b";
		$password = "c";
		$path = "images/";
		$ID = $_POST['ID'];
		$connpt = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); 
		mysql_select_db($database, $connpt);
		$result = mysql_query("SELECT * FROM dealeritems");
		echo   "<table>"; 
		  		 echo "   <tr>".  
       "  <td width=\"100\">".'ID'."</td>"."<td width=\"100\">".'Item Name'."</td>"."<td width=\"150\">".'Item Description'."</td>"."<td width=\"150\">".'Body Copy'."</td>"."<td width=\"100\">".'Image'.
       "  </tr>";
			while ($row = mysql_fetch_assoc($result)) { 
			$ID = $row['ID']; 
			$ItemName = $row['ItemName'];
 		 echo "   <tr>".  
       "  <td width=\"100\">". 
$row['ID']."</td>". 
"<td width=\"100\">". 
$row['ItemName']."</td>". 
"<td width=\"150\">". 
$row['ItemDescription']."</td>". 
"<td width=\"150\">". 
$row['BodyCopy']."</td>". 
" <td width=\"100\"><img src =$path". 
$row['ImageName']." width=\"100\" height=\"125\"></td>". 
"<td width=\"150\">". 
"<input name=\"Order[]\" type=\"radio\" value=\"Ordered.$ID\">"."</td>". 
"<td width=\"150\">". 
"<select name=\"Quantity[]\" id=\"Quantity.$ID\"> 
<option value=\"0\">0</option> 
<option value=\"1\">1</option> 
<option value=\"2\">2</option> 
<option value=\"3\">3</option> 
<option value=\"4\">4</option> 
<option value=\"5\">5</option></select>". 
"</td>"."  </tr>";
}  
echo "</table>";
?>
<p>&nbsp;</p>
<p>
<input type="hidden" name="ID" value="<? echo $_POST['ID']; ?>">
  <input type="submit" name="Submit" value="Submit">
  <input type="reset" name="Reset" value="Reset">
</p>
</form>
<p>&nbsp;</p>
</body>
</html>
And here is the full code for the process page:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?
$id = $_REQUEST['ID'];
$ID = $_POST['ID'];
/*$k = 0; 
$j = 0; 
while($id != 0) 
{ 
   $quantity = $_GET['Quantity'];  
   $ordered = $_GET['Ordered']; 
   foreach ($quantity as $key=>$qty) { 
      echo "Quantity: ".$qty." Ordered: ".$ordered[$key]; 
    } 
} */
$max=100;

echo $ID;
echo $id;
while($id != 0) { 
   $quantity = $_REQUEST['Quantity'];  
   $ordered = $_REQUEST['Ordered']; 
   for($i=1;$i<$max;$i++)  { 
      echo "Quantity: ".$i." Ordered: ".$ordered.$i; 
	  echo $i;
    } 
} 
echo $quantity.$i;
echo $id;
echo $ID;
echo "<br>";
echo "Done!";
echo "<br>";
echo " Thank you for your order. You will be contacted when the order is complete.";
?>
</body>
</html>
You can see I am trying several different suggestions.

BTW, I originally had the Quantity and Ordered as a defined name and now they are a variable. This code was suggested by a user on this forum, and now once you select a product, it "de-selects" the previous product. I know there is a fix for this, also.

I can do a print_r for GET POST REQUEST and I get that info, so I am at the mercy of the users of this forum.

Thanks,

Don


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Fri Apr 15, 2005 9:46 am
by feyd
I believe the logic involved in lines 26 - 33 of process.php are faulty.

Posted: Fri Apr 15, 2005 10:24 am
by dmacman1962
OK, I don't know what wrong with it, but you see something.

Any suggestions?

Also, outside of those lines, I don't understand why an echo of the contents of the GET and POST return nothing?

Thanks,

Don

Posted: Fri Apr 15, 2005 11:10 am
by phpScott
if i read your code right id is the id of the form.

so line 26 of your code is

Code: Select all

while($id != 0) {
what do you get for $id ?

Posted: Fri Apr 15, 2005 12:12 pm
by dmacman1962
That is the problem, if I echo $id, I get zip,nadda, nothing.

Its almost like the values are getting deleted.

On the Form page the Items you can select are from the database and are $id, so I pass those values on to the process page and I get nothing?

Thanks,

Don

Posted: Sat Apr 16, 2005 6:29 am
by phpScott
be careful you have 2 id's one is id the other is ID notice the capilisation difference. The small case is the id of the form the capital ID is the id of the items.

sort that out and it will go along way to solving your problem