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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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]

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.