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