this is the code to email confirm. The user clicks on the link in the email, passing the code through url to this page. Then the data is transferred from a tmp table to main one.
I have queried in phpmyadmin and it works fine. But when i actually use the php i get the "else {echo "error";}" suggesting that the INSERT query is not working. Any suggestions?
include("db_config_db.php");
$code=$_GET['code'];
$sql1="SELECT * FROM table1 WHERE code ='$code'";
$result1=mysql_query($sql1);
if($result1){
$count=mysql_num_rows($result1);
if($count==1){
while($rows=mysql_fetch_array($result1)){
$username = $rows['username'];
$name = $rows['name'];
$email = $rows['email'];
$address = $rows['address'];
$city = $rows['city'];
$state = $rows['state'];
$zip = $rows['zip'];
$phone = $rows['phone'];
$birthday = $rows['birthday'];
$country = $rows['country'];
$description = $rows['description'];
$keywords = $rows['keywords'];
$setup = $rows['setup'];
}
$sql2="INSERT INTO table2 (name, email, address, city, state, zip, phone, birthday, country, description, username, code, keywords, setup)VALUES('$name', '$email', '$address', '$city', '$state', '$zip', '$phone', '$birthday', '$country', '$description', '$username', '$code', '$keywords', '$setup')";
$result2=mysql_query($sql2);
if($result2){
$sql3="DELETE FROM table1 WHERE code = '$code'";
$result3=mysql_query($sql3);
header("location:index.php");
}
else{ echo "error";
}
}
else {
echo "Wrong Confirmation code";
}
}