Advertisement
Guest User

pls sugges for more enhancement .this code has no error

a guest
Dec 22nd, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1. <?php('c:/wamp/tmp/pinpost');session_start();require 'db_connect.php';//code for signing inswitch(isset($_POST)){case(isset($_POST['signinsubmit'])):{if(isset($_POST['username'])){$username = stripslashes(filter_var($_POST['username'],FILTER_SANITIZE_STRING));if(isset($_POST['password0'])){$password0 = sha1(filter_var($_POST['password0'],FILTER_SANITIZE_STRING));}$sth = $dbh->prepare("SELECT *FROM users WHERE username = ? AND password0 = ? ");$sth->bindParam(1,$username);$sth->bindParam(2,$password0);$sth->execute ();if($row_count=$sth->fetch(PDO::FETCH_NUM)){$id=$row_count[0];$username=$row_count[2];$password0=$row_count[3];$password0=crypt($password0);$id=uniqid();$_SESSION['id']=$id;$_SESSION['username']=$username;$_SESSION['password0']=$password0;header('location:dashboard.php?');}else{echo 'wrong password or username';die();}}}break;case(isset($_POST['signupsubmit'])):{if(isset($_POST['e_mail'])){$email= trim(stripslashes(filter_var($_POST['e_mail'], FILTER_SANITIZE_STRING)));if(isset($_POST['username'])){$username= trim(stripslashes(filter_var($_POST['username'],FILTER_SANITIZE_STRING)));}if(isset($_POST['password0'])){$password0= stripslashes(filter_var($_POST['password0'],FILTER_SANITIZE_STRING));}if(isset($_POST['password1'])){$password1= stripslashes(filter_var($_POST['password1'],FILTER_SANITIZE_STRING));}if(strlen($username)♥){echo 'username is too short';die();}if(!ctype_alnum($username)){echo 'username should contain alphanumeric';die();}$sth = $dbh->prepare("SELECT *FROM users WHERE username = ? ");$sth->bindParam(1,$username);$sth->execute();if($row_count=$sth->fetch(PDO::FETCH_NUM)){echo 'the username is already taken';die();}$sth = $dbh->prepare("SELECT *FROM users WHERE email = ? ");$sth->bindParam(1,$email);$sth->execute();if($row_count=$sth->fetch(PDO::FETCH_NUM)){echo 'the email is already taken';die();}if(strlen($password0)♥){echo 'password is too short';die();}if($password0 <> $password1){echo 'password you entered are not equal';die();}else{$password0=sha1($password0);$sth = $dbh-> prepare("INSERTINTO users (email, username, password0, password1,date)VALUES ( ?, ? , ? , ? ,current_TIMESTAMP)");$sth->bindParam(1,$email);$sth->bindParam(2,$username);$sth->bindParam(3,$password0);$sth->bindParam(4,$password1);$sth->execute ();echo 'goodd';die();}}}break;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement