0

Okay so I set up a registration form and everything goes well when registering but when I go and check in MySQL database the row is created but only the id field is filled not the First Name, Second Name, Email and Password.

Here's the .PHP for processing the registration :

mysql_select_db("mlsconnection_99k_dbusers", $con);

$sql="INSERT INTO Persons (FirstName, LastName, Email, Password)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[Email]','$_POST[Password]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "User created, Thanks for Registrating";

mysql_close($con)
?>
2
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by pzuurveen
0

ALLWAYS use mysql_real_escape_string()
or you will be hacked read http://www.php.net/manual/en/security.database.sql-injection.php

mysql_select_db("mlsconnection_99k_dbusers", $con);

$sql="INSERT INTO Persons (FirstName, LastName, Email, Password)
VALUES
(".mysql_real_escape_string($_POST[firstname])."','".mysql_real_escape_string($_POST[lastname])."','".mysql_real_escape_string($_POST[Email])."','".mysql_real_escape_string($_POST[Password])."')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "User created, Thanks for Registrating";

mysql_close($con)

Edited by pzuurveen: n/a

0

Thanks for the help =)

Got any idea why doesn't the form fill the rows?

0

refering to array's in a string doesn't work

sql= "bla $_POST[lastname] bla";

wrong (bla bla)

sql= "$lastname"

ok

sql= "bla ".$_POST[lastname]."bla";

also ok

0

Don't understand you xD how should the code look like? what should I change? :)

0

It gave an error: 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 '','','','')' at line 3

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.