Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

PHP code having some issue

php pdo mysql

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 dennypaul

dennypaul

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 09 March 2019 - 12:37 AM

My code is working fine and inserting data to the database without any issue, except that the md5 password is getting inserted as the plain text. Echo ing out the md5 password is showing the hashed password. Please see the code below. I'm not able to find the issue.

<?php
if(isset($_POST['signup'])){
	$email = $_POST['email'];
	$pass = $_POST['password'];
	$screenname = $_POST['screenName'];

	if(empty($email) || empty($pass) || empty($screenname)){
		$error.="Please fill all the fields";
	}else{
		//Sanitize the data
		$email = $getFromUsers->checkVar($email);
		$pass = md5($getFromUsers->checkVar($pass));
		echo $pass;
		$screenname = $getFromUsers->checkVar($screenname);

		//Check if email format i correct
		if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
			$error.="Please provide valid email";
		}else if(strlen($screenname)>20 || strlen($screenname)<6){
			$error.="Screen Name should have 6-20 Charaters";
		}else if(strlen($pass)<5){
			$error.="Password too weak";
		}else{
			//If all ok, then check if email is available
			if($getFromUsers->checkEmailAvail($email)===true){
				$getFromUsers->create('users',array('username'=>$screenname,'email'=>$email,'password'=>$pass,'screenName'=>$screenname));
				//header('location:./home.php');
			}else $error.="Email not available";
		}
	}
}
?>





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download