Fouten
- Je bent conflicterend
mysql
enmysqli
. name
attribuut is niet gedefinieerd hier<button class="btn btn-sm m-r-5" type="submit">Register</button>
- In register.php je vinkt
isset
. aan met een klas , Dit zal nooit werkenif(isset($_POST['btn-signup']))
- Evenals je Formulier
name
veld en ophalen velden zijn verkeerd .(form -placeholder="Full Name" name="fname"
/ in code -mysql_real_escape_string($_POST['fullname'])
)
Verbeteringen
Wijzig dit
if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
naar dit
if(!empty($_SESSION['user'])){
header("Location: home.php");
}
Bug Fixed-code
In register.php
if(isset($_POST['register'])){
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$uname = mysqli_real_escape_string($conn, $_POST['uname']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$upass = md5(mysqli_real_escape_string($conn, $_POST['pass']));
$sql = "INSERT INTO users(fullname,username,email,password) VALUES('$fname','$uname','$email','$upass')";
if(mysqli_query($conn, $sql))
{
?>
<script>
alert('successfully registered');
</script>
<?php
}
else{
?>
<script>
alert('error while registering you...');
</script>
<?php
}
}
In registration.php
<button class="btn btn-sm m-r-5" type="submit" name="register">Register</button>