I followed this tutorial https://www.youtube.com/watch?v=0BoZc5oUioA to create a connection from a registration form to my database. The php code looks like this:
<?php
$con = mysqli_connect('localhost','root','root');
if(!$con)
{
echo 'Not Connected To Server';
}
if(!mysqli_select_db($con,'register'))
{
echo 'Database Not Selected'
}
$Name = $_POST['username'];
$Email = $_POST['email'];
$sql = "INSERT INTO users (Name, Email) VALUES ('$name','$email')";
if(!mysqli_query($con,$sql))
{
echo 'Not Inserted';
}
else {
echo 'inserted';
}
header("refresh:2; url=index.htm");
?>
However, every time I try out the registration and the new data should be inserted in the database, instead an empty page is displayed in the browser. The database is called "register" and the table is called "users". Has anybody encountered this problem or knows a solution? Or knows a post where somebody targeted this problem as I could not find anything on google. I am helpful for any suggestions!
EDIT:
Here is the html code part where I call the PHP file:
<form action="insert.php" method="post">
Name : <input type=text" name="username">
<br/>
Email : <input type=text" name="email">
<br/>
<input type="submit" value="insert">
</form>