php - form function registration not inserting into database -


after recent topic found out register page not inserting mysql first things first know i'm still using mysql change pdo when evrything working.

so here's thing

the following parts being used insert database

form

    <div id="registerform">     <form action="process.php" method="post">     <ul>         <li>username :         <br />         <?php echo $form->error("user"); ?></li>         <li><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></li>         <li>password :         <br />         <?php echo $form->error("pass"); ?></li>         <li><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></li>         <li>email :         <br />         <?php echo $form->error("email"); ?></li>         <li><input type="text" name="email" maxlength="50" value="<?php echo $form->value("email"); ?>"></li>         <li>first name :<br />         <?php echo $form->error("clan"); ?></li>         <li><input type="text" name="clan" maxlength="30" value="<?php echo $form->value("clan"); ?>" /></li>         <li>last name :<br />         <?php echo $form->error("namers"); ?></li>         <li><input type="text" name="namers" maxlength="30" value="<?php echo $form->value("namers"); ?>" /></li>            <li><input type="hidden" name="subjoin" value="1"><input type="submit" value="register!"></li>      </ul>     </form> </div> 

the following code

process.php

   function procregister(){   global $session, $form;   /* convert username lowercase (by option) */   if(all_lowercase){      $_post['user'] = strtolower($_post['user']);   }   /* registration attempt */   $retval = $session->register($_post['user'], $_post['pass'], $_post['email'], $_post['clan'], $_post['namers']);    /* registration successful */   if($retval == 0){      $_session['reguname'] = $_post['user'];      $_session['regsuccess'] = true;      header("location: ".$session->referrer);   }   /* error found form */   else if($retval == 1){      $_session['value_array'] = $_post;      $_session['error_array'] = $form->geterrorarray();      header("location: ".$session->referrer);   }   /* registration attempt failed */   else if($retval == 2){      $_session['reguname'] = $_post['user'];      $_session['regsuccess'] = false;      header("location: ".$session->referrer);   }    } 

session.php(check errors in form)

    function register($subuser, $subpass, $subemail, $subclan, $subnamers){       global $database, $form, $mailer;  //the database, form , mailer object             /* username error checking */           $field = "user";  //use field name username           if(!$subuser || strlen($subuser = trim($subuser)) == 0){              $form->seterror($field, "* username not entered");       }       else{          /* spruce 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 not alphanumeric */          else if(!ctype_alnum($subuser)){             $form->seterror($field, "* username not alphanumeric");          }          /* check if username reserved */          else if(strcasecmp($subuser, guest_name) == 0){             $form->seterror($field, "* username reserved word");          }          /* check if username in use */          else if($database->usernametaken($subuser)){             $form->seterror($field, "* username in use");          }          /* check if username banned */          else if($database->usernamebanned($subuser)){             $form->seterror($field, "* username banned");          }       }        /* password error checking */       $field = "pass";  //use field name password       if(!$subpass){          $form->seterror($field, "* password not entered");       }       else{          /* spruce password , check length*/          $subpass = stripslashes($subpass);          if(strlen($subpass) < 4){             $form->seterror($field, "* password short");          }          /* check if password not alphanumeric */          else if(!preg_match("/^([0-9a-z])+$/", ($subpass = trim($subpass)))){             $form->seterror($field, "* password not alphanumeric");          }          /**           * note: trimmed password after checked length           * because if fill password field spaces           * looks lot more characters 4, looks           * kind of stupid report "password short".           */       }        /* email error checking */       $field = "email";  //use field name email       if(!$subemail || strlen($subemail = trim($subemail)) == 0){          $form->seterror($field, "* email not entered");       }       else{          /* check if valid email address */          if(!filter_var($subemail, filter_validate_email)){             $form->seterror($field, "* email invalid");          }          $subemail = stripslashes($subemail);       }       /* first name error checking */       $field = "clan";      //use field name clan name       if(!$subclan || strlen($subclan = trim($subclan)) == 0){           $form->seterror($field, "* clan not entered");       }        /* last name error checking */       $field = "namers";        //use field name runescape name       if(!$subnamers|| strlen($subnamers = trim($subnamers)) == 0){           $form->seterror($field, "* runescape name not entered");       }         /* errors exist, have user correct them */       if($form->num_errors > 0){          return 1;  //errors form       }       /* no errors, add new account database*/       else{          if($database->addnewuser($subuser, md5($subpass), $subemail, $subclan, $subnamers)){             if(email_welcome){                $mailer->sendwelcome($subuser, $subemail, $subpass, $subclan, $subnamers);             }             return 0;  //new user added succesfully          }else{             return 2;  //registration attempt failed          }       }       } 

database.php(inserting things)

       function addnewuser($username, $password, $email, $clan, $namers){       $time = time();       /* if admin sign up, give admin user level */       if(strcasecmp($username, admin_name) == 0){          $ulevel = admin_level;       }else{          $ulevel = user_level;       }       $q = "insert ".tbl_users." values ($username, $password, '0', $ulevel, $email, $time, $clan, $namers)";       return mysql_query($q, $this->connection);    } 

the following error being recieved

we're sorry, error has occurred , registration username (name), not completed. please try again @ later time. 

the following code error

    <?php /**  * user logged in, not allowed register.  */ if($session->logged_in){    echo "<h1>registered</h1>";    echo "<p>we're sorry <b>$session->username</b>, you've registered. "        ."<a href=\"main.php\">main</a>.</p>"; } /**  * user has submitted registration form ,  * results have been processed.  */ else if(isset($_session['regsuccess'])){    /* registration successful */    if($_session['regsuccess']){       echo "<h1>registered!</h1>";       echo "<p>thank <b>".$_session['reguname']."</b>, information has been added database, "           ."you may <a href=\"main.php\">log in</a>.</p>";    }    /* registration failed */    else{       echo "<h1>registration failed</h1>";       echo "<p>we're sorry, error has occurred , registration username <b>".$_session['reguname']."</b>, "           ."could not completed.<br>please try again @ later time.</p>";           print_r($_session);      }    unset($_session['regsuccess']);    unset($_session['reguname']); } 

the problem not insert database

it may alot of code hope enough info this

insert query needs quotation marks varchar in values.

$q = "insert ".tbl_users." values ('$username', '$password', '0', '$ulevel', '$email', '$time', '$clan', '$namers')"; 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -