Jump to content


Photo

Trouble with an activation script


  • Please log in to reply
6 replies to this topic

#1 txrandom

txrandom
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 08 August 2006 - 12:27 AM

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.

<?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.";
}
?>

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.

#2 txrandom

txrandom
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 08 August 2006 - 12:53 AM

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.

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

mysql_query("DELETE FROM 'uauser' WHERE 

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

echo "must of worked";

?>

No one has any idea what I'm doing wrong?

#3 txrandom

txrandom
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 08 August 2006 - 01:01 AM

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.

#4 txrandom

txrandom
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 08 August 2006 - 01:52 AM

Well, I found a different way to do a user activation.  But I'm still curious as to why I can't delete it!

#5 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 08 August 2006 - 02:34 AM

Hmm.. Why not just change it to 0 = unactivated and 1 = activated ?

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#6 txrandom

txrandom
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 08 August 2006 - 02:42 AM

Yah, I ended up doing that.  I'm just hoping this problem won't bug me when I absolutely have to be able to delete a row.

#7 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 08 August 2006 - 02:46 AM

Example of deleting..
mysql_query("DELETE FROM `left` WHERE `key` = '$key' LIMIT 1") or die (mysql_error());


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users