- Joined
- Mar 26, 2006
- Messages
- 603
- Reaction score
- 7
Im usin somone elses register and login scripts. Ive edited the register parts to make it imput a profile into mysql ill eventually add edit to it to, Only problem is when i type somethin into the profile part and click submit, says nothins there i need to put somethin into it... heres the 2 parts i had to edit..
Ive looked over this a hundred times to see what my problem could be the mailer part i forgot to put $subprofile but that wont matter unless i enable mailer. Would help alot if somone could help me out with this its the last thing i need basically.
Code:
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></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>Profile:</td><td><input type="text" name="profile" maxlength="500" value="<? echo $form->value("profile"); ?>"></td><td><? echo $form->error("profile"); ?></td></tr>
<tr><td colspan="2" align="right">
<input type="hidden" name="subjoin" value="1">
<input type="submit" value="Register"></td></tr>
<tr><td colspan="2" align="left"><a href="main.php">Back to Main</a></td></tr>
</table>
</form>
<?
Code:
function register($subuser, $subpass, $subemail, $subprofile){
global $database, $form, $mailer; //The database, form and mailer object
/* 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);
}
/* Profile error checking */
$field = "profile"; //Use field name for profile
if(!$subprofile || strlen($subprofile = trim($subprofile)) == 0){
$form->setError($field, "* Profile not entered");
}
else{
/* Spruce up username, check length */
$subprofile = stripslashes($subprofile);
if(strlen($subprofile) < 5){
$form->setError($field, "* Profile below 1 characters");
}
else if(strlen($subprofile) > 500){
$form->setError($field, "* Profile above 500 characters");
}
/* Check if username is not alphanumeric */
else if(!eregi("^([0-9a-z])+$", $subprofile)){
$form->setError($field, "* Profile not alphanumeric");
}
}
/* 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($subuser, md5($subpass), $subemail, $subprofile)){
if(EMAIL_WELCOME){
$mailer->sendWelcome($subuser,$subemail,$subpass, $profile);
}
return 0; //New user added succesfully
}else{
return 2; //Registration attempt failed
}
}
}
Ive looked over this a hundred times to see what my problem could be the mailer part i forgot to put $subprofile but that wont matter unless i enable mailer. Would help alot if somone could help me out with this its the last thing i need basically.