Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>USER AUTHENTICATION</title></head>
- <body><body background=img24.jpg>
- <body text=black></body>
- </html>
- <?php
- //-----------------checks------------------------
- $email = $_POST['email'];
- $uid = $_POST['userid'];
- $psw = $_POST['psw'];
- $repsw = $_POST['psw_re'];
- $firstname = $_POST['firstname'];
- $lastname = $_POST['lastname'];
- $am = $_POST['am'];
- $phone = $_POST['phone'];
- $sem = $_POST['sem'];
- $shauser = sha1($uid);
- $shapass = sha1($psw);
- if(userid_validation($uid,5,12)){
- if(name_validation($firstname,5,12)){
- if(lname_validation($lastname,5,12)){
- if(passid_validation($psw,7,12)){
- if(repassid_validation($psw,$repsw)){
- //<meta http-equiv='refresh' content='0; url=index.php'>;
- // if(filter_var($email, $FILTER_VALIDATE_EMAIL)){
- // }
- $con = mysqli_connect('localhost','root');
- if (!$con) { die('Could not connect ERROR: ' . mysqli_error()); }
- mysqli_select_db($con,"project_awt");
- $insert_query="INSERT INTO student (username,password,am,name,surname,semester,telephone,email)VALUES
- ('".$shauser."','".$shapass."','".$am."','".$firstname."','".$lastname."','".$sem."','".$phone."','".$email."')";
- $select_data= mysqli_query($con,$insert_query);
- $check_validation="SELECT username,password,am,name,surname,semester,telephone,email
- FROM student
- WHERE username='".$shauser."' AND password='".$shapass."'";
- $select_data= mysqli_query($con,$check_validation);
- while ($row = mysqli_fetch_array($select_data)){
- echo "1) am:".$row['am']."<br>";
- echo "2) name:".$row['name']."<br>";
- echo "3) surname:".$row['surname']."<br>";
- echo "4) semester:".$row['semester']."<br>";
- echo "5) tel:".$row['telephone']."<br>";
- echo "6) email:".$row['email']."<br>";
- echo "7) usn:".$uid."<br>";
- echo "8) pwd:".$psw."<br>";
- }
- mysqli_close($con);
- echo "<meta http-equiv='refresh' content='0; url=index.html'>";
- }
- }
- }
- }
- }
- return false;
- function repassid_validation($psw,$repsw){
- if($repsw != $psw){
- echo "<br>Password and re_password is not the same!!";
- return false;
- }else if($repsw == $psw){
- return true;
- }
- }
- function passid_validation($psw,$mx,$my){
- if (strlen($psw) == 0 || strlen($psw) >= $my || strlen($psw) < $mx){
- echo "<br> Password should not be empty / length be between $mx to $my";
- return false;
- }
- return true;
- }
- function lname_validation($uid,$mx,$my){
- if (strlen($uid) == 0 || strlen($uid) >= $my || strlen($uid) < $mx){
- echo "<br> User lastname should not be empty / length be between $mx to $my";
- return false;
- }
- return true;
- }
- function userid_validation($uid,$mx,$my){
- if (strlen($uid) == 0 || strlen($uid) >= $my || strlen($uid) < $mx){
- echo "<br> User Id should not be empty / length be between $mx to $my";
- return false;
- }
- return true;
- }
- function name_validation($uid,$mx,$my){
- if (strlen($uid) == 0 || strlen($uid) >= $my || strlen($uid) < $mx){
- echo "<br> User Name should not be empty / length be between $mx to $my";
- return false;
- }
- return true;
- }
- if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
- echo "<br> mail ok";
- return true;
- }
- else{
- echo "<br> mail not ok";
- return false;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement