I have some data which is received from adobe flash AS3, the PHP file receives it, but I cant seem to send the data to mySQL...
Here is my PHP code:
<?php
if(isset($_POST['userFirstName'])){ $userFirstName = $_POST['userFirstName']; }
if(isset($_POST['userLastName'])){ $userLastName = $_POST['userLastName']; }
if(isset($_POST['userEmail'])){ $userEmail = $_POST['userEmail']; }
if(isset($_POST['userNumber'])){ $userNumber = $_POST['userNumber']; }
if(isset($_POST['userMsg'])){ $userMsg = $_POST['userMsg']; }
$username="******";
$password="*******";
$database="b-elite-fitness";
mysql_connect("localhost","$username","$password") or die (mysql_error());
mysql_select_db("$database") or die (mysql_error());
mysql_query("INSERT INTO formdp
(ID ,firstname, lastname, email, number, message)
VALUES('','$userFirstName[firstname]','$userLastName[lastname]','$userEmail[email]','$userNumber[number]','$userMsg[message]')")
or die (mysql_error());
echo "foo=bar&checking=ok";
mysql_close();
?>
I get this error for the php file...
( ! ) Notice: Undefined variable: userFirstName in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
# Time Memory Function Location 1
0.0094 253176 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userLastName in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
# Time Memory Function Location 1
0.0094 253176 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userEmail in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
# Time Memory Function Location 1
0.0094 253176 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userNumber in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
# Time Memory Function Location 1
0.0094 253176 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userMsg in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
# Time Memory Function Location 1
0.0094 253176 {main}( ) ..\form.php:0
Can anyone help me out I've been going at the problem for the past few days...
I'm new to PHP so could do with explanations as well...
EDIT UPDATE.... I changed the coding, however still get the same errors... here is my new coding....
<?php
if(isset($_POST['userFirstName'])){ $userFirstName = $_POST['userFirstName']; }
if(isset($_POST['userLastName'])){ $userLastName = $_POST['userLastName']; }
if(isset($_POST['userEmail'])){ $userEmail = $_POST['userEmail']; }
if(isset($_POST['userNumber'])){ $userNumber = $_POST['userNumber']; }
if(isset($_POST['userMsg'])){ $userMsg = $_POST['userMsg']; }
$username="root";
$password="dp10aap";
$database="b-elite-fitness";
mysql_connect("localhost","$username","$password") or die (mysql_error());
mysql_select_db("$database") or die (mysql_error());
mysql_query("INSERT INTO formdp
(id ,firstname, lastname, email, number, message)
VALUES('NULL','$userFirstName','$userLastName','$userEmail','$userNumber','$userMsg')")
or die (mysql_error());
mysql_close();
?>
and here are my errors...
( ! ) Notice: Undefined variable: userFirstName in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
Time Memory Function Location
1 0.0112 252456 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userLastName in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
Time Memory Function Location
1 0.0112 252456 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userEmail in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
Time Memory Function Location
1 0.0112 252456 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userNumber in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
Time Memory Function Location
1 0.0112 252456 {main}( ) ..\form.php:0
( ! ) Notice: Undefined variable: userMsg in C:\wamp\www\NewtestForm\form.php on line 18 Call Stack
Time Memory Function Location
1 0.0112 252456 {main}( ) ..\form.php:0
issetcalls are returningfalse, so in fact your PHP is not receiving the data you are POSTing. The problem is elsewhere.mysqlis deprecated, and this code is vulnerable to SQL injection. you should be using placeholders withmysqlior PDONULLinstead of''for your ID field. Presuming you have set the ID field to an auto incrementing integer?