Re: Code Not entering the value in the Database

From: Date: Tue, 20 Jan 2009 14:40:29 +0000
Subject: Re: Code Not entering the value in the Database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-286849@lists.php.net to get a copy of this message
Did I miss something, or you really left the execution of the last $sql? After you put the 'INSERT INTO...' string in $sql, you have to mysql_query it, or you won't get any result. SanTa ----- Original Message ----- From: "Chris Carter" <chandan9sharma@yahoo.com> To: <php-general@lists.php.net> Sent: Tuesday, January 20, 2009 3:34 PM Subject: [PHP] Code Not entering the value in the Database
Hi, My code is not giving error but not doing the desired action. I need to append a value in database just when the user logs in after entering the username and password. So I am not presenting the user with a account but just a thank you page. Steps: 1) User enters the user name and password 2) The login form contains a hidden field with a data 3) After hitting the Submit button the username and password is checked. 4) The hidden data is entered in the database. 5) A mail is sent to the user and he gets a Thank You page. 6) If verification fails then he gets a registeration page. Here is the code, I have been struggling with: <?php //include file for db entries, this part is working fine file.inc $conn = mysql_connect($host, $user, $password) or die(mysql_error()); $db = mysql_select_db($dbName, $conn) or die(mysql_error()); // insert new entry in the database if entry submitted $emailAddress = $_POST['emailAddress']; $password = $_POST['password']; //$_SESSION['testing'] = $_POST['emailAddress']; // insert new entry into database $sql5 = "SELECT * FROM userstable WHERE emailAddress='$emailAddress' AND password = '$password'"; $result5=mysql_query($sql5); // Mysql_num_row is counting table row $count5=mysql_num_rows($result5); // If result matched $myusername and $mypassword, table row must be 1 row if($count5==1){ $rowset5 = mysql_fetch_array($result5); $emailAddress = $rowset5['emailAddress']; $password = $rowset5['password']; //answer insertion $hiddendata= $_POST['hiddendata']; //Email body that is sent to the logged in user. $body = "Hello $fName\n\nThank You for participating"; $sql = "insert into userstable (hiddendata) VALUES ('$hiddendata')"; mail($emailAddress, "Thank you for interest", $body, "From: abc@abc.com"); header("Location: thankYou.php"); } else { header("location:you-need-to-register.php"); } ?> What exactly am I missing. Thanks in advance, Chris -- View this message in context: http://www.nabble.com/Code-Not-entering-the-value-in-the-Database-tp21564252p21564252.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#286849) next »