Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73935

Registration Form : No errors showing on submission, but data not saving in MySql database

$
0
0

I created a registration form that takes 3 inputs from the user and then submits data to MySQL database but in the localhost MySQL, data is not saving. I am PHP Newbie, HELP PLEASE!

My registration.php code :

<?php

    session_start();

    $conn = mysqli_connect('localhost','root','pass','gm-registration');

    $username = $_POST['username'];
    $email = $_POST['email'];
    $password = $_POST['password'];

    $s = "select * from users where username = '$username'";

    $result = mysqli_query($conn, $s);

    $num = mysqli_num_rows($result);

    if($num == 1){
    echo "This Username is Already Taken";
    }
    else{
    $reg = "insert into users(username, email id, password) values('$username', '$email', '$password')";
    mysqli_query($conn, $reg);
    echo "Registration Successful";
    }

    ?>
```html
My `html` form code :
<form id="register" class="input_group" action="registration.php" method="post">
<input type="username" class="input_field" placeholder="Username" name="username">
<input type="email" class="input_field" placeholder="Email Id" name="email">
<input type="password" class="input_field" placeholder="Password" name="password">
<input type="checkbox" class="checkbox" name="checkbox"> <span>I agree to the term & conditions</span>
<button type="submit" class="submit_btn">Register</button>
</form>

Viewing all articles
Browse latest Browse all 73935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>