Jump to content

Getting the $_POSTvariable


s_ainley87

Recommended Posts

Hi,

 

This is probably really simple, I have this code,

 

<form name="modCat" action="modCat.php" method="post">
			<select name="categoryID">
			<?php
			//let's get some data, and put it in a drop down
			$query= "SELECT category_id, category_name FROM category ".
			"ORDER BY category_name";
			$result = mysql_query($query);
			while($row = mysql_fetch_array($result))
			{
			//disply the menu
			echo "<option value=\"".$row['category_id']."\">".$row['category_name']."\n";
			}
			?>
			</select>
			<input type="submit" name="subModCat" value="Submit" />
			</form>

 

As you can see it is creating a drop down menu that gets populated by category_names, the next chain of events if that the user click submit and get directed to a new page where they will fill out a form, I am wanting the form to all ready hold the category name they just selected but cannot find the $_POST that holds it can some help me please?

Link to comment
https://forums.phpfreaks.com/topic/103304-getting-the-_postvariable/
Share on other sites

That would be in $_POST['categoryID']

 

Whenever you want to see what is being passed to your script, put

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>

at the start of your script. This will dump that $_POST array.

 

Ken

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.