<?php
$DBname = "fusion";
$DBuser = "root";
$DBpass = "";
$username=$_POST['txtUsername'];
$userpass=$_POST['txtPassword'];
$confpass=$_POST['txtConfirmPassword'];
$email=$_POST['txtEmail'];
$phone=$_POST['txtPhone'];
$dept=$_POST['txtDept'];
$jobtitle=$_POST['txtJobTitle'];
$submittrue=$_POST['cmdSubmit'];
mysql_connect(localhost, $DBuser, $DBpass);
@mysql_select_db($DBname) or die( "Unable to select database");
//md5 both the password and confirm boxes and test for equality
$md5passvar = md5($userpass);
$md5confvar = md5($confpass);
if ($submittrue == "Submit")
{
//make sure we actually have some data to submit
if ($userpass == "" || $confpass == "" || $email == "" || $username = "")
{
echo "Please fill in all required boxes";
exit;
}
else
{
//if the md5's match
if ($md5passvar == $md5confvar)
{
//set the query string
$query = "INSERT INTO users (username, userpass, email, phone, dept, jobtitle)
VALUES ('$username','$md5passvar','$email','$phone','$dept','$jobtitle')";
//actually do it
mysql_query($query);
//redirect the user to confirmation page
echo "The addition of $username was successful!";
//close mysql
mysql_close();
}
else
{
//redirect user to failure page
echo "The addition of $username has failed!";
//close mysql
mysql_close();
}
}
}
?>
on this line, if I check to see if the username box is empy with this:
if ($userpass == "" || $confpass == "" || $email == "" || $username = "")
it does not add $username to the databse, but if I take it out of the if statement above, it adds username to the database. Funny how it adds both the password and email to the database either way.... Arghh, why does php have to be so picky...