Please can someone help me with this:
<?php
# This is for the registration page
//$page_title = 'Welcome to ADesigns: Registration';
include ('includes/header.html');
// Check if the form has been submitted:
if (isset($_POST['submitted']))
{
$errors = array(); // Initialize an error array.
// Check for a first name:
if (empty($_POST['fname']))
{
$errors[] = 'You forgot to enter your first name.';
}
else
{
$fn = trim($_POST['fname']);
}
// Check for a last name:
if (empty($_POST['lname']))
{
$errors[] = 'You forgot to enter your last name.';
}
else
{
$ln = trim($_POST['lname']);
}
// Check for an email address:
if (empty($_POST['email']))
{
$errors[] = 'You forgot to enter your email address.';
}
else
{
$e = trim($_POST['email']);
}
// Check for a category:
if(isset($_REQUEST['category'])
{
$category = $_REQUEST['category'];
if ($category = 'M')
{
$category = trim($_POST['Men'];
}
else if ($category = 'W')
{
$category = trim($_POST['Women'];
}
else if ($category = 'K')
{
$category = trim($_POST['Kids'];
}
else if ($category = 'U')
{
$category = trim($_POST['Unisex'];
}
else if ($category = 'A')
{
$category = trim($_POST['Accessories'];
}
else if ($category = 'S')
{
$category = trim($_POST['Shoes'];
}
else if ($category = '')
{
$errors[] = "You forgot to select a category.";
}
}
else
{
$errors[] = "You forgot to select a category.";
}
// Check for membership type:
if (isset($_POST['membership']))
{
$membership = $_POST['membership'];
if ($membership = 'designer')
{
$membership = trim($_POST['membership']);
}
else if ($membership = 'visitor')
{
$membership = trim($_POST['membership']);
}
}
else
{
$errors[] = "You forgot to select a membership.";
}
// Check for a loaction:
if (empty($_POST['location']))
{
$errors[] = 'You forgot to enter your location.';
}
else
{
$l = trim($_POST['location']);
}
// Check for an username:
if (empty($_POST['username']))
{
$errors[] = 'You forgot to enter your username.';
}
else
{
$u = trim($_POST['username']);
}
// Check for a password and match against the confirmed password:
if (!empty($_POST['pass1']))
{
if ($_POST['pass1'] != $_POST['pass2'])
{
$errors[] = 'Your password did not match the confirmed password.';
}
else
{
$p = trim($_POST['pass1']);
}
}
else
{
$errors[] = 'You forgot to enter your password.';
}
if (empty($errors))
{
// If everything's OK.
// Register the user in the database...
require_once ('dbc.php'); // Connect to the db.
// Make the query:
// $q - stands for $query
// $r - stands for $result
$q = "INSERT INTO user (fname, lname, email, category, membership, loaction, username, password reg_date ) VALUES ('$fn', '$ln', '$e', '$category', '$membership', '$l', '$u', SHA1('$p'), NOW() )";
$r = @mysql_query ($q); // Run the query.
if ($r)
{
// If it ran OK.
// Print a message:
echo '<h1>Thank you!</h1>
<p>You are now registered. Please <a href="login.php">login</a></p>';
}
else
{
// If it did not run OK.
// Public message:
echo '<h1>System Error</h1>
<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>';
// Debugging message:
echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
} // End of if ($r) IF.
mysql_close($dbc); // Close the database connection.
// Include the footer and quit the script:
include ('includes/footer.html');
exit();
}
else
{
// Report the errors.
echo '<h1>Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg)
{
// Print each error.
echo " - $msg<br />\
";
}
echo '</p><p>Please try again.</p><p><br /></p>';
} // End of if (empty($errors)) IF.
} // End of the main Submit conditional.
?>
<?php
include('includes/footer.html');
?>