Jump to content

Trouble with an activation script


txrandom

Recommended Posts

In my script, the user enters his activation code. If the activation code matches the one found in the database, the users data associated with that activation code is selected from the unactivated user table and added to the activated user table.  My script also deletes activation codes that have already been used.  My only problem is that my script will not delete the row in the unactivated user table.

[code]<?php
include "config.php";

$activation = $_GET['id'];

$query="SELECT * FROM uauser WHERE activation='$activation'";
$result=mysql_query($query);
$num=mysql_num_rows($result);

if ($num > 0 ) {

$row = mysql_fetch_assoc ($result);
$user = $row['user'];
$password = $row['password'];
$realname = $row['realname'];
$email = $row['email'];
$joineddate = $row['joindeddate'];

mysql_query("DELETE FROM 'uauser' WHERE activation='$activation' LIMIT 1");

$query = "INSERT INTO user (user, password, realname, email, joineddate)
VALUES('".$user."','".$password."','".$realname."','".$email."','".$joineddate."')";
$result = mysql_query($query);

echo "Activation successful!";
} else {
echo "Activation unsuccessful.  Your activation code wasn't found.";
}
?>
[/code]

Help is much appreciated.  The deletion codes perfectly in a script that just deletes stuff.  I think since I queried the database before I tried deleting stuff, it is getting messed up.
Link to comment
Share on other sites

I just tried it by itself and it didn't work either.  An exact script but with different table and field names works fine on another part of my site.

[code]<?php
include "config.php";
$activation = $_GET['id'];

mysql_query("DELETE FROM 'uauser' WHERE

activation='$activation'") or die();

echo "must of worked";

?>
[/code]

No one has any idea what I'm doing wrong?
Link to comment
Share on other sites

Could this problem have something to do with my MySQL accounts permissions? I'm going to test this script on my other server and see if it works.  If it does, I think it's a permissions issue.  How do I change an accounts permissions? I lost the walkthrough I use to have.
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.