Jump to content

justin2021

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by justin2021

  1. Great. That helped out a lot. Turns out that the user with access to the database didn't have DELETE enabled in its privileges.
  2. When I run this code, I get a message saying "Record found, failed". I check the database using PHPmyAdmin and the record remains in the temp table. Here is the actual program that I am wanting to run. It stores the data perfectly fine into the users table, but as I stated, the temp data remains. <?php include("connect.php"); //set variable to get passkey from URL $passkey=$_GET['passkey']; $sql1="SELECT * FROM temp WHERE code='$passkey'"; $result1=mysql_query($sql1); //if sucessfully queried if($result1) { echo ("sucessfully queried"); //how many have passkey $count=mysql_num_rows($result1); //if passkey is in database, retrieve data if($count == 1) { $rows = mysql_fetch_array($result1); $namex=$rows['username']; $emailx=$rows['email']; $passwordx=$rows['password']; echo ("<BR>"."sucessfully counted"); //takeout spaces $name=str_replace(' ','',$namex); $email=str_replace(' ','',$emailx); $password=str_replace(' ','',$passwordx); //insert into users table from tmp $sql2="INSERT INTO users (username,email,password) VALUES ('$name','$email','$password')"; $result2=mysql_query($sql2); if($result2) { echo ("<BR>"."SUCESSFUL INSERTION"); //header("Location:sucessful_registration.html"); $sql3="DELETE FROM temp WHERE code='$passkey'"; $result3=mysql_query($sql3); } } } else { echo ("ERROR: Incorrect confirmation code"); } ?>
  3. I'm trying to write a PHP program that a user will use to register to my site. I have a temporary table temp for which the user's information will be stored until they verify their account using an email that is sent to them. Once they verify their account through email, the information stored in the temporary table will be moved to a table called 'users'. I then want to delete the temporary data that they had stored. Unfortunately I'm having trouble doing this. This snippet of code isn't exactly the entire code, but just a test I've been using since I realized that my real code wasn't working as far as deletion goes. Here is my test code. <?php include('connect.php'); $sql2="SELECT username FROM temp WHERE username = 'justin'"; $result2=mysql_query($sql2); if($result2) echo ("Record found"."<BR>"); else echo ("Record not found"); $sql3="DELETE FROM temp WHERE username='justin'"; $result3=mysql_query($sql3); if($result3) echo ("SUCESSFUL DELETION"); else echo ("failed"); ?> In this code, I check the temp table to see if 'justin' can be found. This has consistently returned "Record found". On the other hand, my deletion command has not worked yet and will constantly fail. connect.php is correct as far as I know and has worked flawlessly for the other parts of this small project. Is something wrong here? What could be the problem?
×
×
  • 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.