Hey guys,
Pretty brand new to PHP so learning as I go.
I've got a web form which posts to a file called signup.php. Now within this file i'm trying to take a post variable $_POST[name] and see if its actually empty.
I have an if loop in place to check BUT no matter what I do it doesnt seem to fire. It def has something to do with the code below it because it works when I remove that code.
Anyway, any ideas?
P.S I know its horrible code but im slowly learning bit by bit.
Code:
if ( ! empty($_POST['name']))
{
}
else
{
header('Location:signup.php');
}
// escape user input
$_POST[name] = mysql_real_escape_string($_POST[name]);
$_POST[email] = mysql_real_escape_string($_POST[email]);
$_POST[company] = mysql_real_escape_string($_POST[company]);
$_POST[country] = mysql_real_escape_string($_POST[country]);
$_POST[password] = mysql_real_escape_string($_POST[password]);
// Encrypt the password using MD5
$_POST[password] = md5($_POST[password]);
// store client ip address to variable
$ip = $_SERVER['REMOTE_ADDR'];
// Insert sanitized POST data into the mysql database
$sql="INSERT INTO sellers (name, email, company_name, country, password, ip_address)
VALUES
('$_POST[name]','$_POST[email]','$_POST[company]','$_POST[country]','$_POST[password]','$_POST[ip]')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
header('Location:signupsuccess.php');