Hi all,
Please could you help me out here.
I have created a basic form containing 2text boxes - name, email.
When the user submits his/her details they should store in database.
However, all I get is a blank page.
Here is my PHP code...
<?php
// short variable names
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
if (!$name || !$email)
{
echo 'Please go back and fill in your details.<br />
<a href="javascript:history.back()">Return to fill out form details</a>';
exit;
}
$name = addslashes($name);
$email = addslashes($email);
@ $db = mysql_connect('localhost', 'pass', 'user');
if (!$db)
{
echo 'Sorry. Could not connect to database. Please try again later.<br />
<a href="javascript:history.back()">Return to fill out form details</a>';
exit;
}
mysql_select_db('news');
$query = "insert into subscribers values
('".$name."', '".$email."');
$result = mysql_query($query);
if ($result)
echo 'Congratulations. You have subscribed to our newsletter.';
else
echo 'Error.';
?>
Thanks very much for your help.
Kevin.