Any help for me?

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’);
}
}

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);
}

Should that be $invite ?

Hi @billystonm;

Welcome to the forum.

The solution to your problem is detailed in the expanded error message:

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)

Your function $user->create_account(…) method requires 6 arguments and you have only supplied 5.

Hi Chris, thanks for your reply. Yes $invite suppose to be like that. What am trying to do is users can register by means of friends invitation or normal registration. If its friends invitation registration, the arguments becomes 6 including $invite_code but if its normal registration like user clicks on register link in the site and he or she did, the arguments becomes 5 without $invite_code. Am looking for a way that even though create_account function: originally accepts 6 arguments, it should also accept 5 when the user is registering without invitation.

Hi John, thanks for your reply. What am trying to do is users can register by means of friends invitation or normal registration. If its friends invitation registration, the arguments becomes 6 including $invite_code but if its normal registration like user clicks on register link in the site and he or she did, the arguments becomes 5 without $invite_code. Am looking for a way that even though create_account function: originally accepts 6 arguments, it should also accept 5 when the user is registering without invitation.

Hi billyston,

I think this is what you want…

Take a look at setting “Default argument values” to your function parameters.

http://php.net/manual/en/functions.arguments.php

Using the script below only the first four parameters are mandatory, the last two are optional and have defaults:



public function create_account($username, $email, $password, $plain_password, $signup_ip=true, $invite_code=false)
{
 ...
 ...
 ...

}