Gitlab@Informatics

Skip to content
Snippets Groups Projects
Select Git revision
  • 929491e25c5c08aa407e88f49fc124bdfb33b8d4
  • main default protected
2 results

signup.php

Blame
  • signup.php 3.21 KiB
    <?php
    error_reporting(0);
    if(isset($_POST['submit']))
    {
    $fname=$_POST['fname'];
    $mnumber=$_POST['mobilenumber'];
    $email=$_POST['email'];
    $password=md5($_POST['password']);
    $sql="INSERT INTO  tblusers(FullName,MobileNumber,EmailId,Password) VALUES(:fname,:mnumber,:email,:password)";
    $query = $dbh->prepare($sql);
    $query->bindParam(':fname',$fname,PDO::PARAM_STR);
    $query->bindParam(':mnumber',$mnumber,PDO::PARAM_STR);
    $query->bindParam(':email',$email,PDO::PARAM_STR);
    $query->bindParam(':password',$password,PDO::PARAM_STR);
    $query->execute();
    $lastInsertId = $dbh->lastInsertId();
    if($lastInsertId)
    {
    $_SESSION['msg']="You are Scuccessfully registered. Now you can login ";
    header('location:thankyou.php');
    }
    else 
    {
    $_SESSION['msg']="Something went wrong. Please try again.";
    header('location:thankyou.php');
    }
    }
    ?>
    <!--Javascript for check email availabilty-->
    <script>
    function checkAvailability() {
    
    $("#loaderIcon").show();
    jQuery.ajax({
    url: "check_availability.php",
    data:'emailid='+$("#email").val(),
    type: "POST",
    success:function(data){
    $("#user-availability-status").html(data);
    $("#loaderIcon").hide();
    },
    error:function (){}
    });
    }
    
    if (isset($_POST['register'])) {
        $email = $_POST['email'];
        $password = $_POST['password'];
    
        // เข้ารหัสรหัสผ่าน
        $hashed_password = password_hash($password, PASSWORD_DEFAULT);
    
        $sql = "INSERT INTO tblusers (EmailId, Password) VALUES (:email, :password)";
        $query = $dbh->prepare($sql);
        $query->bindParam(':email', $email, PDO::PARAM_STR);
        $query->bindParam(':password', $hashed_password, PDO::PARAM_STR);
        $query->execute();
    }
    
    </script>
    
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    				<div class="modal-dialog" role="document">
    					<div class="modal-content">
    						<div class="modal-header">
    							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>						
    						</div>
    							<section>
    								<div class="modal-body modal-spa">
    									<div class="login-grids">