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>";
	}
}

Link to comment
Share on other sites

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.