Help with search

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Skullgrabber
Forum Newbie
Posts: 4
Joined: Sun Aug 17, 2008 8:09 pm

Help with search

Post 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.
Corvin
Forum Commoner
Posts: 49
Joined: Sun Dec 03, 2006 1:04 pm

Re: Help with search

Post 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
Post Reply