Page 1 of 1

Help with search

Posted: Wed Aug 20, 2008 11:27 am
by Skullgrabber
Hey everyone,
This is my second script with PHP, but I'm getting better. Slowly. I have the following code:

Code: Select all

 
<body>
<?
include_once "connect_users.php";
if($_POST['submit'])
{
    if($_POST['submit'] != NULL)
    {
        $find=$_POST['vertification'];
        $data = mysql_query("SELECT `vertification` FROM users WHERE '$find'") or die(mysql_error());
        while($result = mysql_fetch_array( $data ))
        {
            echo "Code is: ".$result[$to_find];
        }
    }
}
else
{
echo '<p>Please enter your vertification code in the box below.</p>
<form name="form1" method="post" action="">
  <label>
  <input name="vertification" type="text" id="vertification">
  </label>
  <label>
  <input type="submit" name="submit" id="submit" value="Submit">
  </label>
</form>
<p>&nbsp;</p>';
}
?>
</body>
 
I have a table in a database that has a column named vertification. It has a unique code that differs from every user. For starters, I want to see if the code they imput matches the one in the table. To go about this, I tried to perform a simple search using

$data = mysql_query("SELECT `vertification` FROM users WHERE '$find'") or die(mysql_error());

But the script doesn't echo anything. Sorry if I'm being unclear, but any help is appreciated. Thanks.

Re: Help with search

Posted: Wed Aug 20, 2008 11:40 am
by Corvin
Your query should look like this:

Code: Select all

SELECT 
   `vertification` 
FROM 
   `users` 
WHERE 
   `vertification` = '$find'
And have a look at this:
:arrow: http://php.net/manual/en/security.datab ... ection.php