Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Edytowanie skryptu na wlasne potrzeby
Forum PHP.pl > Forum > Przedszkole
MarcinJarek
Witam,

Mam 3 pliki:

register.php:

  1. <form action="process.php" method="POST">
  2. <table align="left" border="0" cellspacing="0" cellpadding="3">
  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>
  4. <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>
  5. <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>
  6. <tr><td>MoneyBookers:</td><td><input type="text" name="mb" maxlength="50" value="<? echo $form->value("mb"); ?>"></td><td><? echo $form->error("mb"); ?></td></tr>
  7. <tr><td>Egold:</td><td><input type="text" name="egold" maxlength="50" value="<? echo $form->value("egold"); ?>"></td><td><? echo $form->error("egold"); ?></td></tr>
  8. <tr><td colspan="2" align="right">
  9. <input type="hidden" name="subjoin" value="1">
  10. <input type="submit" value="Join!"></td></tr>
  11. <tr><td colspan="2" align="left"><a href="main.php">Back to Main</a></td></tr>
  12. </form>


session.php:


  1. <?php
  2.    function register($subuser, $subpass, $subemail){
  3.       global $database, $form, $mailer;  //The database, form and mailer object
  4.       
  5.       /* Username error checking */
  6.       $field = &#092;"user\";  //Use field name for username
  7.       if(!$subuser || strlen($subuser = trim($subuser)) == 0){
  8.          $form->setError($field, &#092;"* Username not entered\");
  9.       }
  10.       else{
  11.          /* Spruce up username, check length */
  12.          $subuser = stripslashes($subuser);
  13.          if(strlen($subuser) < 5){
  14.             $form->setError($field, &#092;"* Username below 5 characters\");
  15.          }
  16.          else if(strlen($subuser) > 30){
  17.             $form->setError($field, &#092;"* Username above 30 characters\");
  18.          }
  19.          /* Check if username is not alphanumeric */
  20.          else if(!eregi(&#092;"^([0-9a-z])+$\", $subuser)){
  21.             $form->setError($field, &#092;"* Username not alphanumeric\");
  22.          }
  23.          /* Check if username is reserved */
  24.          else if(strcasecmp($subuser, GUEST_NAME) == 0){
  25.             $form->setError($field, &#092;"* Username reserved word\");
  26.          }
  27.          /* Check if username is already in use */
  28.          else if($database->usernameTaken($subuser)){
  29.             $form->setError($field, &#092;"* Username already in use\");
  30.          }
  31.          /* Check if username is banned */
  32.          else if($database->usernameBanned($subuser)){
  33.             $form->setError($field, &#092;"* Username banned\");
  34.          }
  35.       }
  36.  
  37.       /* Password error checking */
  38.       $field = &#092;"pass\";  //Use field name for password
  39.       if(!$subpass){
  40.          $form->setError($field, &#092;"* Password not entered\");
  41.       }
  42.       else{
  43.          /* Spruce up password and check length*/
  44.          $subpass = stripslashes($subpass);
  45.          if(strlen($subpass) < 4){
  46.             $form->setError($field, &#092;"* Password too short\");
  47.          }
  48.          /* Check if password is not alphanumeric */
  49.          else if(!eregi(&#092;"^([0-9a-z])+$\", ($subpass = trim($subpass)))){
  50.             $form->setError($field, &#092;"* Password not alphanumeric\");
  51.          }
  52.          /**
  53.           * Note: I trimmed the password only after I checked the length
  54.           * because if you fill the password field up with spaces
  55.           * it looks like a lot more characters than 4, so it looks
  56.           * kind of stupid to report \"password too short\".
  57.           */
  58.       }
  59.  
  60.       /* Email error checking */
  61.       $field = &#092;"email\";  //Use field name for email
  62.       if(!$subemail || strlen($subemail = trim($subemail)) == 0){
  63.          $form->setError($field, &#092;"* Email not entered\");
  64.       }
  65.       else{
  66.          /* Check if valid email address */
  67.          $regex = &#092;"^[_+a-z0-9-]+(.[_+a-z0-9-]+)*\"
  68.                  .&#092;"@[a-z0-9-]+(.[a-z0-9-]{1,})*\"
  69.                  .&#092;".([a-z]{2,}){1}$\";
  70.          if(!eregi($regex,$subemail)){
  71.             $form->setError($field, &#092;"* Email invalid\");
  72.          }
  73.          $subemail = stripslashes($subemail);
  74.       }
  75.  
  76.   $field = &#092;"egold\";
  77.       if(!$subegold){
  78.          $form->setError($field, &#092;"* egold not entered\");
  79.           }
  80.  
  81.       $field = &#092;"mb\";  //Use field name for password
  82.       if(!$submb){
  83.          $form->setError($field, &#092;"* mb not entered\");
  84.           }
  85.       /* Errors exist, have user correct them */
  86.       if($form->num_errors > 0){
  87.          return 1;  //Errors with form
  88.       }
  89.       /* No errors, add the new account to the */
  90.       else{
  91.          if($database->addNewUser($subuser, md5($subpass), $subemail)){
  92.             if(EMAIL_WELCOME){
  93.                $mailer->sendWelcome($subuser,$subemail,$subpass);
  94.             }
  95.             return 0;  //New user added succesfully
  96.          }else{
  97.             return 2;  //Registration attempt failed
  98.          }
  99.       }
  100.    }
  101. ?>



process.php:

  1. <?php
  2.    function procRegister(){
  3.       global $session, $form;
  4.       /* Convert username to all lowercase (by option) */
  5.       if(ALL_LOWERCASE){
  6.          $_POST['user'] = strtolower($_POST['user']);
  7.       }
  8.       /* Registration attempt */
  9.       $retval = $session->register($_POST['user'], $_POST['pass'], $_POST['email']);
  10.       
  11.       /* Registration Successful */
  12.       if($retval == 0){
  13.          $_SESSION['reguname'] = $_POST['user'];
  14.          $_SESSION['regsuccess'] = true;
  15.          header(&#092;"Location: \".$session->referrer);
  16.       }
  17.       /* Error found with form */
  18.       else if($retval == 1){
  19.          $_SESSION['value_array'] = $_POST;
  20.          $_SESSION['error_array'] = $form->getErrorArray();
  21.          header(&#092;"Location: \".$session->referrer);
  22.       }
  23.       /* Registration attempt failed */
  24.       else if($retval == 2){
  25.          $_SESSION['reguname'] = $_POST['user'];
  26.          $_SESSION['regsuccess'] = false;
  27.          header(&#092;"Location: \".$session->referrer);
  28.       }
  29.    }
  30. ?>




Oto moj błąd:

Nawet, gdy wpisze pole "mb" i "egold" pojawia sie, ze nie wpisalem tych danych....Jak to naprawić? Prosze też, żeby ktoś jak będzie poprawiał, odrazu zrobił, że trzeba albo pole mb wypełnić albo pole egold.

Odwdzięcze się :-)
Gość_misz
Umiejętność kreowania treściwych i wyczerpujących wypowiedzi chyba już w tym narodzie zanikła.

Wykaż się choć odrobiną samodzielności!

Cierpliwości racz mi dać Panie...
MarcinJarek
Probowalem wszystkiego...a gdy dam:
  1. <?php
  2.  
  3. function register($subuser, $subpass, $subemail, $subegold, $summb){//na ta linijke pokazuje blad.
  4. global $database, $form, $mailer;  //The database, form and mailer object
  5.  
  6. ?>


Na poczatku pliku session.php to pojawia sie blad:


Cytat
Warning: Missing argument 4 for register() in /home/addicted/public_html/hosting/include/session.php on line 247

Warning: Missing argument 5 for register() in /home/addicted/public_html/hosting/include/session.php on line 247

Warning: Cannot modify header information - headers already sent by (output started at /home/addicted/public_html/hosting/include/session.php:247) in /home/addicted/public_html/hosting/process.php on line 111



To pomoze mi ktoś?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.