Re: [PHP] Code Not entering the value in the Database




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@xxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
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@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


.



Relevant Pages

  • Re: Techniques for Vulneability discovery
    ... in mind) so i searched the net for some free database driven software and came ... the first thing i did was grab some info about PHP programming and some MySQL ... I did some more reasearch on different types of web based "input validation" ... PHP and SQL docs, etc.. ...
    (Vuln-Dev)
  • Re: Techniques for Vulneability discovery
    ... in mind) so i searched the net for some free database driven software and came ... the first thing i did was grab some info about PHP programming and some MySQL ... I did some more reasearch on different types of web based "input validation" ... PHP and SQL docs, etc.. ...
    (Security-Basics)
  • Help! PHP/SQL Brain freeze
    ... This is my first venture into PHP and SQL so i'm pretty much throwing ... this database and displayed in the browser window. ... I've set up apache http server and PHP ... stopped working completely. ...
    (comp.lang.php)
  • Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??
    ... I even had one tell me "SQL injection? ... The big Daddy database spends lots of CPU cycles on the big Momma ... And PHP can't be used for foreign language sites, ...
    (php.general)
  • Re: [PHP] To check for existing user in database
    ... cohabitation of PHP and XML. ... // Connect and select the database. ... // Insert new entry in the database if entry submitted ... // Output an error message to the user. ...
    (php.general)