I'm very new to PHP and coding, and am trying to learn - but I'm stuck and was hoping someone could point out what's wrong -
My code is showing text "Failure" as soon as I open my page. My goal is to have "Failure" only show when the user inputs information and it fails to connect to the database.
I'm using WAMP and my database server is in MySQL. Additionally, when I click "Register" I'm not getting any results in my database - and no error message to indicate why.
<?php
require('connect.php');
$username = @$_POST['username'];
$password = @$_POST['password'];
$repass = @$_POST['repassword'];
$Email = @$_POST['email'];
if(isset($_POST['submit']))
{
if($query = mysqli_query("INSERT INTO users (`id`, `username`, `password`, `email`) VALUES ('', '".$username."', '".$password."', '".$Email."')"))
echo "Success";
}else{
echo "Failure";
}
?>
<?php
$connect = mysqli_connect("localhost", "root", "") or die("Couldn't connect to server");
mysqli_select_db($connect, "php_forum") or die("Couldn't connect to database");
?>
Please help! Let me know if I have not explained what is occurring well enough