0

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

Edited by megachip04: n/a

4
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by rv1990
0

Not completely sure what you mean, but yes, mysql typically works. The first SELECT is working, but the INSERT INTO is not.

1

do use die function every mysql statement such as
mysql_query("select * from fdf) or die("not working1");
u can able to detect which function is not working....
Tell me if u find any error

Votes + Comments
good
0

$username = $rows;
$name = $rows;
$email = $rows;
$address = $rows;
$city = $rows;
$state = $rows;
$zip = $rows;
$phone = $rows;
$birthday = $rows;
$country = $rows;
$description = $rows;
$keywords = $rows;
$setup = $rows;
}

make sure ur html textboxes names is same as ur given index name

ex.
$setup = $rows; = <input type=text name="setup">

0

i'm not posting to the page through the form. I'm selecting them from the database

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.