post the form part as well please. your mail function looks okay, however i could add some debugging things such as echo "email: $email"; and then do a test run through your whole script and see where it is going wrong..
here is my validation for a website that only requires username/email
$flag = '1'; // this is a flag to make sure we don't have any errors from input
$feedback = "\n";
$username = stripslashes($HTTP_POST_VARS['username']);
// match username versus database to see if we get a match
$sql = "select username from {$DB_CONF['table_images_account']} where username='$username'";
$sql_result = mysql_query($sql) or die ("Couldn't execute query. (message_database()) ".mysql_error());
while ($row = mysql_fetch_array($sql_result)) {
$username_test = $row['username'];
}
if ( $username_test == $username ) { // okay someone already has that username..
$errormsg .= "Someone already has chosen $username.. please select another username.\n";
$flag = '0';
}
// no spaces in username
if (strrpos($username,' ') > '0') {
$errormsg .= "There cannot be any spaces in the login name.\n";
$flag = '0';
}
// illegal names
if (eregi("((root)|(bin)|(daemon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)"
. "|(uucp)|(operator)|(games)|(mysql)|(httpd)|(nobody)|(dummy)"
. "|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download))$",$username)) {
$errormsg .= "Illegal username.\n";
$flag = '0';
}
if (eregi("(anoncvs)",$username)) { // check for CVS in username
$errormsg .= "Name is reserved for CVS.\n";
$flag = '0';
}
// validate email
if( !ereg( "([0-9,a-z,A-Z]+)(.,)@(.,_\,-).{2}([0-9,a-z,A-Z])?$", $email ) ) {
// email didn't pass check, redirect.
$errormsg .= "Your email address is <b>not valid</b> ..please enter a valid email address.\n";
$flag = '0';
}
if (!$flag) { // okay we have an error somewhere.. let's inform the user of it
echo "
<head>
<title>Error in Input</title>
</head>
<body>
<h1>There was an error in your input</h1>
error message:<p>
<pre>
<p align=left>$errormsg</p>
</pre>
<h3>Please click back on your browser and try to correct the errors.</h3>
</body>
";
}
else if ($flag) { // this means user has inputted correct values.. inserting into database
$sql = "INSERT INTO {$DB_CONF["table_images_account"]}
(username,password,email,creation, last_visit)
VALUES (\"$username\",\"$password\",\"$email\",\"$date\", \"$date\")";
$sql_result = mysql_query($sql) or die ("Couldn't execute query. (add_to_database()) ".mysql_error());
// getting account_id
$user_id = do_login($username, $password);
// let's send a message to the user so they have something to read
// authentication.
if ($user_id > '1') { // if this passes, we have a valid account
// start a session for the user
session_name("User_Session"); // session name: User_Session
session_start(); // start a session
$sid = session_id(); //get a session_id
session_register("sid"); // register it within our session
// session variables //
$logged_in = '1';
$current_username = $username;
$user_id = do_login($username,$password);
$current_user_id = $user_id;
// add to session //
session_register("current_username");
session_register("current_user_id");
session_register("logged_in");
// create directory for user
create_index($current_username, $current_user_id);
// okay now we have their generic index.html file
addlogin($user_id);
if ( $current_user_id > '1' ) { // this makes sure we have a user_id
echo "
<head>
<meta HTTP-EQUIV=\"refresh\" CONTENT=\"1;URL=$user/index.php\">
</head>
<body>
Account Created Successfully!
<P>
<h3>Redirecting..</h3>
</body>
";
}
} // end *good* user authentication
else {
echo "
Account Creation Failed.
<p>
<a href=\"http://www.fandelem.com/contact.html\">Problem or Question?</a>
<p>
";
$directory = "/home/kdavis/images/";
include("$directory" . "login.html");
return 0;
}
} // end else ifblock for $flag
but yeah, post your html portion -- it might look like the problem lies within there.
~kyle