I get the following error message when I try to run the code below ( Warning: Missing argument 6 for User::create_account(), called in /Applications/MAMP/htdocs/ghalive.com/register.php on line 64 and defined in /Applications/MAMP/htdocs/ghalive.com/includes/classes/user.class.php on line 165)
registration.php
if (DEMO_MODE == ‘ON’)
{
$message = “<div class=‘notification-box warning-notification-box’><p>Sorry, you can’t do that while demo mode is enabled.</p><a href=‘#’ class=‘notification-close warning-notification-close’>x</a></div><!–.notification-box .notification-box-warning end–>”;
}
else
{
if ($username != “” && $email != “” && $password != “” && $repeat_password != “”)
{
if($password == $repeat_password)
{
if(!$check_username)
{
if(!$check_email)
{
if (ALLOW_REGISTRATIONS == “NO”)
{
if($invite)
{
// now that everything is ok, we can now register the user.
$plain_password = $password;
$password = md5($password);
$user->create_account($username, $email, $password, $plain_password, $signup_ip, $invite_code);
}
else
{
$message = “<div class=‘notification-box warning-notification-box’><p>Sorry, but that invite code does not exist.</p><a href=‘#’ class=‘notification-close warning-notification-close’>x</a></div><!–.notification-box .notification-box-warning end–>”;
}
}
else
{
// now that everything is ok, we can now register the user.
$plain_password = $password;
$password = md5($password);
$user->create_account($username, $email, $password, $plain_password, $signup_ip);
}
}
else
{
$message = “<div class=‘notification-box warning-notification-box’><p>Sorry, but that email address has already been taken.</p><a href=‘#’ class=‘notification-close warning-notification-close’>x</a></div><!–.notification-box .notification-box-warning end–>”;
}
}
else
{
$message = “<div class=‘notification-box warning-notification-box’><p>Sorry, but that username has already been taken.</p><a href=‘#’ class=‘notification-close warning-notification-close’>x</a></div><!–.notification-box .notification-box-warning end–>”;
}
}
else
{
$message = “<div class=‘notification-box warning-notification-box’><p>Passwords don’t match.</p><a href=‘#’ class=‘notification-close warning-notification-close’>x</a></div><!–.notification-box .notification-box-warning end–>”;
}
}
else
{
$message = “<div class=‘notification-box warning-notification-box’><p>Please complete all required fields.</p><a href=‘#’ class=‘notification-close warning-notification-close’>x</a></div><!–.notification-box .notification-box-warning end–>”;
}
}
}
else
{
// Form has not been submitted.
$username = “”;
$email = “”;
$password = “”;
$repeat_password = “”;
$invite_code = “”;
}
?>
create_account function:
public function create_account($username, $email, $password, $plain_password, $signup_ip, $invite_code)
{
global $database;
$session = new Session();
// Generate the users ID.
$user_id = generate_id();
$sql = “SELECT * FROM “.self::$levels_table_name.” WHERE auto = ‘1’”;
$query = $database->query($sql);
$row = $database->fetch_array($query);
$user_level = $row[‘level_id’];
$flag = false;
//until flag is false
while ($flag == false)
{
//check if the user id exists
$sql = “SELECT * FROM “.self::$table_name.” WHERE user_id = ‘{$user_id}’”;
$query = $database->query($sql);
$rows = $database->num_rows($query);
//if it does try again till you find an id that does not exist
if ($rows){
$user_id = generate_id();
}else{
//if it does not exist, exit the loop
$flag = true;
}
}
if ($flag == true)
{
//insert into database the data
$datetime = strftime(“%Y-%m-%d %H:%M:%S”, time());
if(VERIFY_EMAIL == “NO”){$activated = 1;} else if(VERIFY_EMAIL == “YES”){$activated = 0;}
$sql = “INSERT INTO “.self::$table_name.” VALUES (‘’ ‘$username’, ‘$email’, ‘$password’, ‘$user_level’, ‘0’, ‘’, ‘$activated’, ‘0’, ‘$datetime’, ‘’, ‘0’, ‘$signup_ip’, ‘’, ‘0’, ‘’, ‘’, ‘’)”;
$database->query($sql);
if (ALLOW_REGISTRATIONS == “NO”)
{
$sql = "DELETE FROM “.self::$invites_table_name.” WHERE code = ‘{$invite_code}’ ";
$database->query($sql);
}
// Send and email to the user.
if(VERIFY_EMAIL == “NO”)
{
// Initialize functions.
$email_class = new Email();
// Email sent to the user if logged in.
$from = SITE_EMAIL;
$subject = "Welcome to “.SITE_NAME.” ";
$message = $email_class->email_template(‘registration_success’, “$plain_password”, “$username”, “”, “”);
$email_class->send_email($email, $from, $subject, $message);
} else if(VERIFY_EMAIL == “YES”) {
//$activation_hash = Activation::set_activation_link($email)
Activation::set_activation_link($plain_password, $email);
}
// Create the message that will be displayed on the login screen once the user has been redirected.
$session->message(“<div class=‘notification-box success-notification-box’><p>Your account has been created successfully. Please check your email for activation link.</p><a href=‘#’ class=‘notification-close success-notification-close’>x</a></div><!–.notification-box .notification-box-success end–>”);
// redirect the user to the login page.
redirect_to(‘login.php’);
}
}