Code Not entering the value in the Database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx");
		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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux