15 thoughts on “PHP MySQLi Registration Tutorial

  • January 28, 2019 at 10:43

    Hi I hope you are well?
    I took my name Victor, I am 22 years in first year of the BTS in Computer Network and Telecom.
    To practice I created a website in php but I have trouble with my database. The liason is there but I can not connect or open an account.
    At first I use MYSQL and when I proceed to the user account login I encounter a problem that I am advised to use MYSQLI or PDO for my database:

    ( ! ) Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:wamp64wwwnewcoredatabaseconnect.php on line 8

    I tried but no change. I do not know what approach to use. If you please, I will send you the site in compressed form by your email so that you can help me. My email is traoregeeker@gmail.com.

    Thank you

  • January 28, 2019 at 10:43

    Not Work for me <?php
    $output = NULL;

    if (isset($_POST['submit'])){

    //connect to database a habibi
    $mysqli = NEW MySQLi('localhost','root','','socres');

    $username = $mysqli->real_escape_string($_POST['username']);
    $email = $mysqli->real_escape_string($_POST['email']);
    $password = $mysqli->real_escape_string($_POST['password']);
    $cpassword = $mysqli->real_escape_string($_POST['cpassword']);
    $gender = $mysqli->real_escape_string($_POST['gender']);

    $query = $mysqli->query("SELECT * FROM users WHERE username = '$username'");

    if(empty($username) OR empty($email) OR empty($password) OR empty($cpassword) OR empty($gender)){
    $output = "Please Fill in All Fields.";
    }elseif($query->num_rows != 0){

    $output = "that username already Taken.";
    }elseif ($cpassword !=$password) {
    $output = "Youre password Do'nt Match.";
    }elseif (strlen($password) < 6) {
    $output = "Youre password must be at least 5 characters.";
    //Encryption Password
    $password =md5($password);
    //insert the record
    $insert = $mysqli->query("SELECT INTO users (username,email,password,gender) VALUES('$username','$email','$password','$gender')");
    if ($insert != TRUE){
    $output = "There Was a Problem <br />.";
    $output .= $mysqli->error;
    $output = "You Have Been Registred!";




  • January 28, 2019 at 10:43

    I would like to take this opportunity to highly appreciate and thank you for the wonderful work. i finally understood what i have been trying to understand for awhile.
    i would like to contact u directly for future questions i might be having.

  • January 28, 2019 at 10:43

    When i reload the page it will automatically inserted last input data
    in the database. If i reload again then it will again inserted last
    input data. Also if i put new data then it inserted the current new
    data. again after inserted new data if i reload the page (without
    giving nothing in the input field) then it automatically inserted last
    new data.

    student_name student_city
    DON india
    DON india (same data )


    <title>insert data in database using mysqli</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <form id="form1" method="post" action="<?php echo
    htmlspecialchars($_SERVER['PHP_SELF']); ?>">
    <label>Student Name :</label>
    <input type="text" name="stu_name" id="name" required="required"
    placeholder="Please Enter Name"/><br /><br />

    <label>Student City :</label>
    <input type="text" name="stu_city" id="city" required="required"
    placeholder="Please Enter Your City"/><br/><br />

    <input type="submit" name="submit" id="submit" value="Submit Data" /><br />


    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "college";

    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection

    if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);

    //$name = $email = $city = "";
    $name= ($_POST['stu_name']);
    $city= ($_POST['stu_city']);
    echo "$name" . "<br/>";
    echo "$city" . "<br/>";

    $sql = "INSERT INTO students (student_name, student_city) VALUES
    echo "$sql";

    if (mysqli_query($conn,$sql))
    echo "<br/> " . "<br/> " . "<br/> " . "New record created


    //echo "<br/> " . "<br/> " . "<br/> " . "Not successfull";





    please help me —-i dont want want to redirect the page to other page…….for processing……

  • January 28, 2019 at 10:43

    Thanks, I've watched 20 tutorials and this is the only good one with clear instructions!

  • January 28, 2019 at 10:43

    Thank you so much, you're such a great teacher. Your videos are really easy to follow. I said thank you in another video, but this was an awesome breakdown.

Leave a Reply