mikebyrne Posted November 30, 2007 Share Posted November 30, 2007 I've just created a field in the users table called users. I want my code to pass a 1 to that field when the user click on the confirmation link. What extra would i add to my SQL? <?php include('config.php'); $passkey=$_GET['passkey']; // Passkey that got from link ## added here if (!isset($_GET['passkey'])) { echo "Error here :: PASSKEY NOT FOUND "; } else { ## table name $tbl_name="temp_users"; $tbl_name2="users"; // after connecting succesfully: $query = "SELECT * FROM $tbl_name WHERE confirm_code ='$passkey'"; $result = mysql_query($query) or die(mysql_error()); // while there is a result, fetch it into an array... while ($row = mysql_fetch_array($result)) { $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "')"; $result2=mysql_query($sql)or die(mysql_error()); echo "Your account has been activated"; } } ?> Link to comment https://forums.phpfreaks.com/topic/79487-solved-adding-to-my-sql-statement/ Share on other sites More sharing options...
phpQuestioner Posted November 30, 2007 Share Posted November 30, 2007 you should use a MySQL Update in your if else condition. here is a tutorial that you can review: http://www.tizag.com/mysqlTutorial/mysqlupdate.php Link to comment https://forums.phpfreaks.com/topic/79487-solved-adding-to-my-sql-statement/#findComment-402519 Share on other sites More sharing options...
mikebyrne Posted November 30, 2007 Author Share Posted November 30, 2007 Thanks I just played around with the code and solved it while ($row = mysql_fetch_array($result)) { $sql="INSERT INTO $tbl_name2(name, address, address1, address2, address3, address4, county, zip, telephone, email, username, password, user)VALUES('".$row['name'] . "', '".$row['address'] . "', '".$row['address1'] . "', '".$row['address2'] . "', '".$row['address3'] . "', '".$row['address4'] . "', '".$row['county'] . "', '".$row['zip'] . "', '".$row['telephone'] . "', '".$row['email'] . "', '".$row['username'] . "', '".$row['password'] . "', 1)"; $result2=mysql_query($sql)or die(mysql_error()); echo "Your account has been activated"; } Link to comment https://forums.phpfreaks.com/topic/79487-solved-adding-to-my-sql-statement/#findComment-402523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.