hello, if any of you have heard of jpmaster777's login system, im using that
reference: http://evolt.org/node/60384
ive added other variables before, but this time when ive tried to add another 6 variables i keep getting registration failed, wonder if anyone could take a brief look at the code and suggest the correct way to add another variable..
here is how i do it:
register.php: add required fields
<tr><td>Company:</td><td><input type="text" name="company" maxlength="30" value="<? echo $form->value("company"); ?>"></td><td><? echo $form->error("company"); ?></td></tr>
<tr><td>First Name:</td><td><input type="text" name="firstname" maxlength="30" value="<? echo $form->value("firstname"); ?>"></td><td><? echo $form->error("firstname"); ?></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lastname" maxlength="50" value="<? echo $form->value("lastname"); ?>"></td><td><? echo $form->error("lastname"); ?></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" maxlength="50" value="<? echo $form->value("email"); ?>"></td><td><? echo $form->error("email"); ?></td></tr>
<tr><td>Tel:</td><td><input type="text" name="tel" maxlength="50" value="<? echo $form->value("tel"); ?>"></td><td><? echo $form->error("tel"); ?></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" maxlength="50" value="<? echo $form->value("address"); ?>"></td><td><? echo $form->error("address"); ?></td></tr>
<tr><td>Website:</td><td><input type="text" name="website" maxlength="50" value="<? echo $form->value("website"); ?>"></td><td><? echo $form->error("website"); ?></td></tr>
<tr><td>Username:</td><td><input type="text" name="user" maxlength="50" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="50" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
session.php: add the variables
/**
* register - Gets called when the user has just submitted the
* registration form. Determines if there were any errors with
* the entry fields, if so, it records the errors and returns
* 1. If no errors were found, it registers the new user and
* returns 0. Returns 2 if registration failed.
*/
function register($subcompany, $subfirstname, $sublastname, $subemail, $subtel, $subaddress, $subwebsite, $subuser, $subpass){
global $database, $form, $mailer; //The database, form and mailer object
/* company error checking */
$field = "company"; //Use field name for number
if(!$subcompany || strlen($subcompany = trim($subcompany)) == 0){
$form->setError($field, "* Company not entered");
}
/* firstname error checking */
$field = "firstname"; //Use field name for number
if(!$subfirstname || strlen($subfirstname = trim($subfirstname)) == 0){
$form->setError($field, "* First name not entered");
}
/* lastname error checking */
$field = "lastname"; //Use field name for number
if(!$sublastname || strlen($sublastname = trim($sublastname)) == 0){
$form->setError($field, "* Last name not entered");
}
/* tel error checking */
$field = "tel"; //Use field name for number
if(!$subtel || strlen($subtel = trim($subtel)) == 0){
$form->setError($field, "* Number not entered");
}
/* address error checking */
$field = "address"; //Use field name for number
if(!$subaddress || strlen($subaddress = trim($subaddress)) == 0){
$form->setError($field, "* Address not entered");
}
/* website error checking */
$field = "website"; //Use field name for number
if(!$subwebsite || strlen($subwebsite = trim($subwebsite)) == 0){
$form->setError($field, "* Website not entered");
}
/* Username error checking */
$field = "user"; //Use field name for username
if(!$subuser || strlen($subuser = trim($subuser)) == 0){
$form->setError($field, "* Username not entered");
}
else{
/* Spruce up username, check length */
$subuser = stripslashes($subuser);
if(strlen($subuser) < 5){
$form->setError($field, "* Username below 5 characters");
}
else if(strlen($subuser) > 30){
$form->setError($field, "* Username above 30 characters");
}
/* Check if username is not alphanumeric */
else if(!eregi("^([0-9a-z])+$", $subuser)){
$form->setError($field, "* Username not alphanumeric");
}
/* Check if username is reserved */
else if(strcasecmp($subuser, GUEST_NAME) == 0){
$form->setError($field, "* Username reserved word");
}
/* Check if username is already in use */
else if($database->usernameTaken($subuser)){
$form->setError($field, "* Username already in use");
}
/* Check if username is banned */
else if($database->usernameBanned($subuser)){
$form->setError($field, "* Username banned");
}
}
/* Password error checking */
$field = "pass"; //Use field name for password
if(!$subpass){
$form->setError($field, "* Password not entered");
}
else{
/* Spruce up password and check length*/
$subpass = stripslashes($subpass);
if(strlen($subpass) < 4){
$form->setError($field, "* Password too short");
}
/* Check if password is not alphanumeric */
else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){
$form->setError($field, "* Password not alphanumeric");
}
/**
* Note: I trimmed the password only after I checked the length
* because if you fill the password field up with spaces
* it looks like a lot more characters than 4, so it looks
* kind of stupid to report "password too short".
*/
}
/* Email error checking */
$field = "email"; //Use field name for email
if(!$subemail || strlen($subemail = trim($subemail)) == 0){
$form->setError($field, "* Email not entered");
}
else{
/* Check if valid email address */
$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
."\.([a-z]{2,}){1}$";
if(!eregi($regex,$subemail)){
$form->setError($field, "* Email invalid");
}
$subemail = stripslashes($subemail);
}
/* Errors exist, have user correct them */
if($form->num_errors > 0){
return 1; //Errors with form
}
/* No errors, add the new account to the */
else{
if($database->addNewUser($subcompany, $subfirstname, $sublastname, $subemail, $subtel, $subaddress, $subwebsite, $subuser, md5($subpass))){
if(EMAIL_WELCOME){
$mailer->sendWelcome($subcompany,$subfirstname,$sublastname,$subemail,$subtel,$subaddress,$subwebsite,$subuser,$subpass);
}
return 0; //New user added succesfully
}else{
return 2; //Registration attempt failed
}
}
}
process.php: add the fields to get the data from
/* Registration attempt */
$retval = $session->register($_POST['company'], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $_POST['tel'], $_POST['address'], $_POST['website'], $_POST['user'], $_POST['pass']);
database.php: add my variables
/**
* addNewUser - Inserts the given (username, password, email)
* info into the database. Appropriate user level is set.
* Returns true on success, false otherwise.
*/
function addNewUser($company, $firstname, $lastname, $email, $tel, $address, $website, $username, $password){
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
/* If admin sign up, give admin user level */
if(strcasecmp($username, ADMIN_NAME) == 0){
$ulevel = ADMIN_LEVEL;
}else{
$ulevel = USER_LEVEL;
}
$q = "INSERT INTO ".TBL_USERS." VALUES ('0', '$company', '$firstname', '$lastname', '$email', '$tel', '$address', '$website', '$username', '$password', $ulevel, '$time', '$ip')";
return mysql_query($q, $this->connection);
}
and in constants.php ive edited the database config to suit:
define("DB_SERVER", "localhost");
define("DB_USER", "msuk_support");
define("DB_PASS", "---------");
define("DB_NAME", "msuk_clients");
/**
* Database Table Constants - these constants
* hold the names of all the database tables used
* in the script.
*/
define("TBL_USERS", "client_details");
define("TBL_ACTIVE_USERS", "active_users");
define("TBL_ACTIVE_GUESTS", "active_guests");
define("TBL_BANNED_USERS", "banned_users");
i know this is a biggy! but all help would be apppreciated