Jump to content

This works...kinda


quiksilver02x

Recommended Posts

I have a script to check for duplicate username's on signup.  Even when there is no entry found and the script preforms the update statement, the error will come back indicating the requested name already exists.

 

#Check to see if requested name already exists
$name = $_POST['name'];
$siteid = $_POST['siteid'];
$checkname = mysql_query("SELECT * FROM projects WHERE url = '$name'");
$founduser = mysql_num_rows($checkname);

if ($founduser != 0) {
echo"$name already exists in the database.  Please select another name";}

if ($founduser == 0) {
mysql_query("UPDATE projects SET url = '$name' WHERE siteid = $siteid"); die; echo"URL updated successfully";}

 

If I remove the UPDATE statement and simply return an echo statement for each IF statement, everything works fine:

 

if ($founduser != 0) {
echo"$name already exists in the database.  Please select another name";}

if ($founduser == 0) {
echo"$name is available";}

 

So what's happening is, when $founduser == 0, the update script preforms just fine and the database is populated correctly, but then the entire script will then re-run itself and find the name that was just entered, resulting in $founduser != 0. 

:wtf:

 

How do I stop the script when it preforms the UPDATE statement?  I tried putting die; in after the UPDATE statement, but the entire script still re-runs itself.  I am pulling my hair out here...

Link to comment
Share on other sites

  • 2 weeks later...

When I saw your response I thought...Oh yeah!!  I figured it was the solution, but I am still having the same problem. 

 

I'm using jQuery to send the data to my PHP script...could there be something weird going on there?  I have tried everything possible to make the script work but have had no luck. 

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.