Registration Code in PHP



<!DOCTYPE html>

<html lang="en">

    <head>

        <meta charset="UTF-8">

        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>Document</title>

        <style>

        #menu{

        height:50px;

        width:750px;

        background:black;

        border:1px solid black;

        position:sticky;

        top:0px;

        }

        #menu ul{

        list-style:none;

        }

        #menu ul a li{

        height:40px;

        width:120px;

        font-size:40px;

        float:left;

        margin-left:50px;

        color:white;

        border-radius:5px;

        transform-translate(-2px);

        margin-top:-18px;

        

        }

        #menu ul a li:hover{

        background:white;

        color:black;

        transition: all ease 1s ;

        }

        </style>

    </head>

    <body>

        <div id="menu">

            <ul>

                <a href="show.php"><li>show</li></a>

                <a href=""><li>edit</li></a>

                <a href=""><li>delete</li></a>

                <a href="login.php"><li>Login</li></a>

                

            </ul>

            

        </div>

        <h1>::Register Here::</h1>

        <form action="rgcode.php?/=<?php echo basename($_SERVER['PHP_SELF']);?>" method="POST">

            Enter a Name:

            <p>

                <input type="text" name="name">

            </p>

            Enter Email:

            <p>

                <input type="email" name="email">

            </p>

            Enter Mobile Number:

            <p>

                <input type="text" name="mobile">

            </p>

            Enter password:

            <p>

                <input type="password" name="password">

            </p>

            <input type="submit" name="submit" value="submit">

            

        </form>

        <h3>All reserved @copy </h3>

    </body>

</html>




<?php

include_once 'dbconnect.php' ;

if($_SERVER['REQUEST_METHOD']=='POST'){

if(isset($_POST['submit']) and !empty($_POST['submit'])){

$name = isset($_POST['name'])?$_POST['name']:NULL;

$pass =isset($_POST['password'])?$_POST['password']:NULL;





if(is_null($name) or empty($name)){

header("location:{$_REQUEST['/']}?action=name&msg=blank-name");

exit;

}

$email =isset($_POST['email'])?$_POST['email']:NULL;

if(is_null($email) or empty($email)){

header("location:{$_REQUEST['/']}?action=email&msg=blank-email");

exit;

}

if(is_null($pass) or empty($pass)){

header("location:{$_REQUEST['/']}?msg=blank-password");

exit;

}

$mobile =isset($_POST['mobile'])?$_POST['mobile']:NULL;


if(is_null($mobile) or empty($mobile)){

header("location:{$_REQUEST['/']}?msg=blank-mobile");

exit;

}




$insertquery ="insert into vritant_tbl(name,email,mobile,password) values

('$name','$email','$mobile','$pass')";

$iquery =mysqli_query($conn,$insertquery);

if($iquery){

//$last_id = mysqli_insert_id($conn);

?>

<script>

window.alert("registration successfully");

window.location.href="register.php";

</script>

<?php

}else{

?>

<script>

window.alert("registration failed");

window.location.href="register.php";

</script>

<?php

}

}else{

header("location:{$_REQUEST['/']}");

}


}else{

header("location:register.php");

}

?>

Registration Code in PHP