Jump to content

[SOLVED] HELP - UNIQUE FORM VALIDATION?


jmalouff

Recommended Posts

I am working on a basic PHP Form that when submitted does a quick error check. All Works Well in my development environment. 

 

However when form is on the live server all does as it is supposed to but when doing the error checking one of the forms request the end user to enter a Affiliate code of their choice! I want these to be unique! so if a user enters one that was already entered previously  it attempts to query the database for an duplicate. this way i can make sure that each Code entered is unique.  However online it submits with out giving an error and it allows duplicates to enter the database.

 

In my development environment when i submit the form  with the same file it errors out saying that the

 

Here is my code.

 

/* Begin Unique Affiliate Code Check */

 

 

$sql = "SELECT * FROM affiliates WHERE affiliate_code='".$affiliate_code."'";

$res = mysql_query($sql) or die (mysql_error());

 

if (mysql_num_rows ($res) > 0) {

$curnum ++;

echo "<tr><td>".$curnum.". The Affiliate Code ' <b>".$affiliate_code."</b> ' already exists </tr></td>";

 

 

 

}

 

/* End Unique Affiliate Code Check */

 

am i doing something wrong? any suggestions?

Link to comment
Share on other sites

If you can, modify that field in the table to be "UNIQUE" this will prevent duplicates from being entered at the SQL level.

 

As far as why that is not returning the affiliates like it should, try trim ing the data and check if Magic Quotes are enabled on the production server, as that may be escaping data. If it is I would suggest turning them off or using get_magic_quotes_gpc to test if it is on if it is, do a stripslashes on the data.

Link to comment
Share on other sites

Thanks for your help!

 

Here is what i found in RE: to my php.ini (Magic Quotes) - Is this the right area?

 

; Magic quotes

;

 

; Magic quotes for incoming GET/POST/Cookie data.

magic_quotes_gpc = On

 

; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.

magic_quotes_runtime = Off

 

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.