Fejl
- Du modstrider
mysql
ogmysqli
. name
attribut er ikke defineret her<button class="btn btn-sm m-r-5" type="submit">Register</button>
- I register.php du tjekker
isset
med en klasse , Dette vil aldrig virkeif(isset($_POST['btn-signup']))
- Savel som dit Formular
name
felter og hentefelter er forkerte .(form -placeholder="Full Name" name="fname"
/ i kode -mysql_real_escape_string($_POST['fullname'])
)
Forbedringer
Skift dette
if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
til dette
if(!empty($_SESSION['user'])){
header("Location: home.php");
}
Fejlrettet kode
I 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
}
}
I registration.php
<button class="btn btn-sm m-r-5" type="submit" name="register">Register</button>