Jump to content

What am I missing here? (PEAR Validate package)


Far Cry

Recommended Posts

Okay so I am using PEAR's Validate package to validate a few values in my form, it validates the username just fine, but is for some reason returning false on the password field, even if the credentials are correct. Here is the link to the package (http://pear.php.net/package/Validate/)

 

Here is the code:

<?php require("Validate.php");?>
<?php require("styles/top.php");?>
<?php
$validate = new Validate();
?>
<div id="head_reg">
<div id="head_cen_reg">
  <div id="head_sup_reg" class="head_height_reg">
    <?php require("scripts/newsfeed.php"); ?>
   <?php require("scripts/links.php"); ?>
    </div>
    </div>
    </div>
<div id="content">
<br />
<?php
if(isset($_POST['reg-btn'])){
$username = strip_tags ($_POST['username']);
$email = strip_tags($_POST['email']);
$password = strip_tags($_POST['pass']);
$repassword = strip_tags($_POST['repass']);
if ($username && $password && $repassword && $email){
if($validate->string($username,$options = array(
'format' => VALIDATE_ALPHA,
'min_length' => 6,
'max_length' => 50))){
 if($validate->string($password,$options = array(
'format' => VALIDATE_ALPHA,
'min_length' => 6,
'max_length' => 32))){
  if ($password == $repassword){

			if ($validate->email($email,$options = array(
          'check_domain' => 'true',
          'fullTLDValidation' => 'true',
          'use_rfc822' => 'true',
          'VALIDATE_GTLD_EMAILS' => 'true',
          'VALIDATE_CCTLD_EMAILS' => 'true',
          'VALIDATE_ITLD_EMAILS' => 'true',
          ))){


				$query = mysql_query("SELECT * FROM users WHERE username='$username'");
				$numrows = mysql_num_rows($query);
				if ($numrows == 0){

					$query = mysql_query("SELECT * FROM users WHERE email='$email'");
					$numrows = mysql_num_rows($query);
					if ($numrows == 0){



					    

						$pass = md5(md5($password));
						$ip = $_SERVER['REMOTE_ADDR'];
						$date = date("F, d, Y g:i:s A");

						mysql_query("INSERT INTO users VALUES ('', '$username', '$pass', '$email','Member', '$date','','0','$ip', '0')");
						echo"<center>Thanks, $username! You have completed the registration process and may now login <a href=\"login.php\"><b>here!</b></center>";


          
		   }
	    else
		   echo"<center><font color=\"#FF0000\">That email is already in use!</font></center>";
		   }
		     else 
			    echo"<center><font color=\"#FF0000\">That username is already taken!</font></center>";
                    }
                      else
                          echo"<center><font color=\"#FF0000\">That email is invalid!</font></center>";
                        
                           }
                             else
                                 echo"<center><font color=\"#FF0000\">Those passwords do not match!</font></center>";	
                                 } 
							 else
							   echo"<center><font color=\"#FF0000\">Your password must be betweed 6 and 25 characters long!</font></center>";
                                    }
							  else
								echo"<center><font color=\"#FF0000\">Your username must be between 6 and 50 characters long!</font></center>";
                                     
								}
							 else
							    echo"<center><font color=\"#FF0000\">You did not fill out the entire form!</font></center>";
                                    }
						       
                                
                                         
                             
                                             										  
?>

<div id="register_form">
<form action="register.php" method="post" enctype="multipart/form-data">
<center>
<table>
   <tr>
     <td>Desired Username </td>
     <td><input type="text" name="username" class="textbox"  value="<?php $_POST['username'];?>"/></td>
   </tr>
   <tr>
     <td>E-Mail </td>
     <td><input type="text" name="email" class="textbox" value="<?php $_POST['email'];?>" /></td>
   </tr>
   <tr>
     <td>Password </td>
     <td><input type="password" name="pass" class="textbox" /></td>
   </tr>
   <tr>
     <td>Confirm Password </td>
     <td><input type="password" name="repass" class="textbox" /></td>
   </tr>
   <tr>
     <td><p class="register">
    <input name="reg-btn" type="submit" class="btn" value="REGISTER" />
   </p></td>
   </tr>
</table>
</center>
</form>
</div>
<center><a href="#" id="showreg">Why register? Click here</a></center>
<div id="content_cen">
  <div id="content_sup">
   <div id="welcom_pan">
   <h3><span>Why</span> Register?</h3>
   <p>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla vitae diam magna, eget fringilla tellus. Curabitur est velit, suscipit eu faucibus eget, aliquam ac enim. per inceptos himenaeos. Nulla vitae diam magna, eget fringilla tellus.</p>
   </div>
  </div>
</div>
</div>
<div id="foot_reg">
<div id="foot_cen_reg">
<ul>
    
   </ul>
    <p></p>
</div>
</div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.