Jump to content

got form to work, but one problem


silverglade

Recommended Posts

Awesome, after stripping off about 90% of my code, I found a tiny little error that made the whole thing not work. It was a form error. lol. So I have it working as a tiny skeleton now where it can return data matched LIKE a date of birth in database. But when it doesn't, it is supposed to echo "Sorry there was nothing in db matching that". But that message never appears. Please any advice appreciated. thank you. and that will be it for the night/morning now. lol

 

 

<?php 
$host		= " ";
$database 	= " ";
$username 	= " ";
$password 	= " *";
$tbl_name   = "users";
$conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error());
mysql_select_db($database);



if(isset($_POST['submit'])) 

{

			 $dob= $_POST['dob'];

			  $result = mysql_query("SELECT * FROM users
			 	WHERE dob LIKE '%$dob'");

			if ($result)
			{
				while($row = mysql_fetch_array($result))
				  {
				  echo $row['dob'] ;
				  echo "<br />";
				  echo "CONGRATS!! you found one matching date of birth in the DB!";
				  }
			}
			else
			{
			echo "<br/> sorry ". $dob . "for date of birth is not in the database";	
			}

}


?>
<html>
<body>

<form action="login_successBACKUP02.php" method="post">


    <input name="dob" type="text" size="20" id="dob" />
    Date of Birth<br />
   
    <input type="submit" name="submit" value="Search database" />
    <input type="reset" value="Reset fields" />


</form> 
  

</body>
</html>

 

 

Link to comment
Share on other sites

thank you, I made some major changes to the script. I think it is close to doing what I want. I want to enter user data in the form, and the form echoes out any matching data from the database. The problem is, when I type in a 5 for the date of birth form field, all of the $rows, echo out a 5. I didn't want to post all of the code it is long, so I just posted this. Please if anyone can understand it I need help. Thank you.

 

 

		 
 	//THE SEARCH FUNCTION
$result = mysql_query ( "SELECT * FROM users WHERE dob  LIKE '%$dob%' OR gender LIKE '%$gender%' OR race  LIKE 	'%$ethnic%' OR job  LIKE '%$job%' OR country  LIKE '%$country%' OR state  LIKE '%$state%' OR town  LIKE '%$town%'  OR zip  LIKE'%$zip%' OR hobbies  LIKE'%hobbies%' OR business  LIKE '%$business%' OR religion  LIKE'%$religion%' OR social_groups  LIKE '%$social%' OR political_groups  LIKE'%$political%' OR other_affiliations LIKE ' %$affiliations%' OR  buying  LIKE '%$buying%' OR selling  LIKE '%$selling%' OR links  LIKE '%$links%' OR  likes  LIKE '%$likes%' OR dislikes  LIKE'%$dislikes%'");  			 



	 if ($result)
	 	{ 
			 while($row = mysql_fetch_array($result))
			  {
				  //put the results on the screen
				 		if ($row=$_POST['dob'])  echo $row['dob']." date of birth<br/>" ; 
						if ($row['gender'])echo $row['gender']." gender <br/>" ; 
						if ($row['race'])echo $row['race']." ethnicity <br/>" ; 
						if ($row['job'])echo $row['job']."job <br/>"; 	
						if ($row['country'])echo $row['country']."country <br/>"; 
						if ($row['state'])echo $row['state']." state<br/>"; 	


						if ($row['town'])echo $row['town']." town<br/>";
						if ($row['zip'])echo $row['zip']." zip<br/>";
						if ($row['hobbies'])echo $row['hobbies']." hobbies<br/>";
						if ($row['business'])echo $row['business']." business<br/>";
						if ($row['religion'])echo $row['religion']." religion<br/>";
						if ($row['social'])echo $row['social']." social<br/>";
						if ($row['political'])echo $row['political']." political<br/>";
						if ($row['affiliations'])echo $row['affiliations']." affiliations<br/>";
						if ($row['buying'])echo $row['buying']."buying <br/>";
						if ($row['selling'])echo $row['selling']." selling<br/>";
						if ($row['links'])echo $row['links']." links<br/>";
						if ($row['likes'])echo $row['likes']." likes<br/>";
						if ($row['dislikes'])echo $row['dislikes']." dislikes<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.