Hi, I need urgent help with a novice problem. I would appreciate any
advice, suggestions... Thanks a lot in advance! Here it is:
I created a sign-up sheet (reg.html) where people fill in their first
name, last name, email, etc. The data are then sent to a PHP script
(reg.php). The data are then inserted into a table (reg) in MS SQL
server. I have declared the variables like this:
if (!(isset($_POST['FirstName']))) {
$FirstName = "" ;
} else {
$FirstName = $_POST['FirstName'] ;
}
Then I said the following to make sure people fill in all the info:
if(empty($First Name) OR empty($LastName ) OR empty($Email))
{
echo "Oops, you must complete the form to register. Please use the
browser back button to go back and complete the form.";
echo "</body></html>";
exit;
}
The statement that insert the data to the table is like this:
$qry = "insert into reg values ('$FirstName',' $LastName','$Em ail')";
However, this doesn't work. I looked into examples online, but none of
the "insert into" statements handle varibles (they all insert actual
values such as "Hanna, Smith, hs@yahoo.com', etc.)
Could you tell me what went wrong with this script? I am pretty sure
the problem originates from the "insert" statement.
Thanks!
A PHP Newbie
advice, suggestions... Thanks a lot in advance! Here it is:
I created a sign-up sheet (reg.html) where people fill in their first
name, last name, email, etc. The data are then sent to a PHP script
(reg.php). The data are then inserted into a table (reg) in MS SQL
server. I have declared the variables like this:
if (!(isset($_POST['FirstName']))) {
$FirstName = "" ;
} else {
$FirstName = $_POST['FirstName'] ;
}
Then I said the following to make sure people fill in all the info:
if(empty($First Name) OR empty($LastName ) OR empty($Email))
{
echo "Oops, you must complete the form to register. Please use the
browser back button to go back and complete the form.";
echo "</body></html>";
exit;
}
The statement that insert the data to the table is like this:
$qry = "insert into reg values ('$FirstName',' $LastName','$Em ail')";
However, this doesn't work. I looked into examples online, but none of
the "insert into" statements handle varibles (they all insert actual
values such as "Hanna, Smith, hs@yahoo.com', etc.)
Could you tell me what went wrong with this script? I am pretty sure
the problem originates from the "insert" statement.
Thanks!
A PHP Newbie
Comment