Jump to content

form submission code for thankyou.php page to insert form data into user table?


macers

Recommended Posts

I am unable to get the user form data to insert into my mysql database.  I have the action="thankyou.php" and have placed the following php code top that page....

 

<?php
require_once( 'nipadmin/config.php' );
require_once( 'nipadmin/utils.php' );
session_start();

define('DB_HOST', 'db_host');
define('DB_USER', 'db_user');
define('DB_PASS', 'db_pass');
define('DB_NAME', 'db_name');

if ($dbConn = mysql_connect(DB_HOST, DB_USER, DB_PASS))
{
	if (mysql_select_db(DB_NAME, $dbConn))
	{
		$firstName = mysql_real_escape_string($_POST['firstname']);
		$lastName = mysql_real_escape_string($_POST['lastname']);
		$phone = mysql_real_escape_string($_POST['phone']);
		$state = mysql_real_escape_string($_POST['state']);
		$event = mysql_real_escape_string($_POST['event']);
		$siteCode = mysql_real_escape_string($_POST['scode']);
		$ipAddress = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);

		$dbQuery = mysql_query("INSERT INTO user_signup
						(event_id, firstname, lastname, email, phone, state, sitecode, ip_address, date)
						VALUES (".$event.", '".$fistName."', '".$lastName."', '".$email."', '".$phone."', '".$state."', '".$siteCode.", '".$ipAddress."', ".time().")", $dbConn);
		if (!$dbQuery) { print '<!-- MySQL Error: '.mysql_error().' -->'; }
	}
	else { print '<!-- MySQL Error: '.mysql_error().' -->'; }
}
else { print '<!-- MySQL Error: '.mysql_error().' -->'; }
?>

 

 

Can somebody let me know what is keeping my script from submitting the form data input by the user...I've been stumped for sometime now...need help.  thanks in advance! If this is of any help here is the site with the form....www.newinvestorpreview.com

 

Collin

 

Why are all of the mysql_error()s in html comment tags? Have you viewed the page source to see if there are any errors showing in it? I'd suggest echoing your query string out to make sure it contains the values you'd expect it to contain also.

MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '209.189.246.194', 1279429203)' at line 3

 

Any idea what that 209 and 127 number means?  I deleted the html comment code...thanks.

'".$siteCode." <- MISSING a single quote(');

 

Full Line:

$dbQuery = mysql_query("INSERT INTO user_signup(event_id, firstname, lastname, email, phone, state, sitecode, ip_address, date)
VALUES (".$event.", '".$fistName."', '".$lastName."', '".$email."', '".$phone."', '".$state."', '".$siteCode."', '".$ipAddress."', ".time().")", $dbConn);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.