Jump to content

Just need to check if a record exists in one field


jdintexas

Recommended Posts

Pehaps this is kidstuff but i'm a kid at heart.

 

I have only 1 form field on a form

User enters a special code in the form.

Once submitted the form is queried against a mysql database to see if the code exists.

If code does not exist it must be reentered.

If code exists then redirected.

 

basically its like "get to the next page if you have the code"

 

thanks

 

Yes, we need more information and what you are actually stuck on.  If you need to do the entire thing we can tell you HOW to do it and point you in the right direction.

 

Pehaps this is kidstuff but i'm a kid at heart.

 

What is kidstuff?

yeah. i'm an old cold fusion programmer and my php skills are rusty  to non existence. just need to be directed to the right place.

"kids stuff" meaning easy on a php level but obviously not to me. sorry if seemed offensive.

thanks.

 

yeah. i'm an old cold fusion programmer and my php skills are rusty  to non existence. just need to be directed to the right place.

"kids stuff" meaning easy on a php level but obviously not to me. sorry if seemed offensive.

thanks.

 

 

No, I did not take offense to it, just misinterpretation on my part (but thanks for clarifying).

 

Try something like this (sorry haven't tested it):

if(isset($_POST['submit']))
{
   $code = mysql_real_escape_string($_POST['code']);
   $query = "SELECT * from [table][tr][td] WHERE code = '$code'";
   $result = mysql_query($query) or die(mysql_error());
   if($mysql_num_rows($result) > 0)
   {
      echo "Code already exists";
   }
   else
   {
      echo "Code is free";
   }
}
?>

</pre>
<form action="" method="POST">
   
   
<

[/td][/tr][/table]

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.