okay, i just did this registration code and it says that im calling an undefined function, “valid_email” though i made the function in the beginning, heres the code:
<?php
function filled_out($form_vars)
{
foreach($form_vars as $key => $value)
{
if(!isset($key) || ($value == '')){
return flase;
}
return true;
}
function valid_email($email)
{
if(ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-+\.]+$', $address))
return true;
else
return flase;
}
function db_connect()
{
$result = mysql_pconnect('localhost', 'tucker_tucker', 'raymond');
if(!result)
return false;
if(!mysql_select_db('tucker_users'))
return false;
return $result;
}
function register($username, $email, $password)
{
$conn = db_connect();
if (!$conn)
return 'Could not connect to the databse, please try again later';
$result = mysql_query("select * from user where username='$username'");
}
if(!$result)
return'Could not execute query';
if(mysql_num_rows($result)>0)
return 'That username is taken- go back and chose a different username.';
$result = mysql_query("insert into user values('$username', password('$password'), '$email')");
if (!$result)
return 'Could not register you in database - please try again later.';
return true;
}
$username = $HTTP_POST_VARS['username'];
$email = $HTTP_POST_VARS['email'];
$password = $HTTP_POST_VARS['password'];
$confirm = $HTTP_POST_VARS['confirm'];
session_start();
if(!filled_out($HTTP_POST_VARS)){
echo 'You have not filled out all of the form, please go back and try again';
exit;
}
if(!valid_email($email)){
echo 'The email adress you entered was not valid, please go back and try again';
exit;
}
if(strlen($password)<6 || strlen($password)>16){
echo 'Your password is an invalid length, please go back and try again';
exit;
}
if($password != $confirm){
echo 'Your passwords do not match, please go back and try again';
exit;
}
$reg_result = register($username, $email, $password);
if($reg_result == true){
$HTTP_SESSION_VARS['valid_user'] = $username;
echo 'Your registration was successful!';
}
else{
echo $reg_result;
exit;
}
?>