Jump to content

Wierd checkbox form submit problem (must click submit twice)


burntheblobs

Recommended Posts

I have a search form that reads both an input field and a checkbox selection. It seems that when I check the appropriate checkbox and enter in an appropriate search query, nothing is echoed. However, if I check the correct checkbox again, then hit submit again, it will echo the correct results, just like it is suppose to.

 

Here is the form code in my html section:

					<form method="post" action="search.php">
				          
				<input type="text" size="45" maxlength="45" name="date_Name" style="vertical-align:middle;">
				<input type="image" SRC="images/searchbutton.png" ALT="Submit button" style="vertical-align:middle;"><br>
				          
				<input type="radio" name="checkBox" value="name">Name 
				<input type="radio" name="checkBox" value="school">School
				</form>

 

And here is the procession section:

if ($_POST[checkBox] == "name")
{

$query = "SELECT dateName FROM date WHERE dateName LIKE '%$_POST[date_Name]%' ORDER BY dateName";
$result = mysqli_query($cxn,$query)
		or die ("Couldn't execute query.");
showInfo($result);
}

function showInfo($result)
{
	while ($row = mysqli_fetch_assoc($result))
	{
		extract($row);
		echo "<a href='viewdate.php?date=$dateName'>$dateName</a><br><br>";
	}
}

1. The submit is in the middle so it appears as an input field with the search button lined up, then the checkboxes on a different line. Aesthetics. (don't forgot this is a search form!)

2. Placing the function at the top does not solve the problem.

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.