I have been stuck on this for 3 days now and any help would be very much appreciated. Please note that i have the php and html in one page for now until i get it working then once it has been fixed i will place the php connection script into its usual folder. when I get onto the sign up page i can see that i am connected to my and i can fill out my form and submit it without any errors, however the database will not be updated and when i refresh the database no new users are found. Below is my code so far if anyone could show me what i am doing wrong or where i could improve to fix this error i would be trully thankfull. Thank you in advance!
<?php
$host="localhost";
$dbuser="root";
$pass="********";
$dbname="amsadler";
$con = mysqli_connect ($host, $dbuser, $pass, $dbname);
if (mysqli_connect_errno ())
{
die ("Connection Failed!" . mysqli_connect_error());
}
else
{
echo "Connected to database {$dbname} ";
}
if(isset($_POST['submit']))
{
$fname = mysqli_real_escape_string($con, $_POST ['fname']);
$lname= mysqli_real_escape_string($con, $_POST ['lname']);
$email= mysqli_real_escape_string($con, $_POST ['email']);
$pswrd= mysqli_real_escape_string($con, $_POST ['pswrd']);
$sql = $con->query("INSERT INTO users ( fname, lname, email, pswrd,)
VALUES ( ' {$fname} ' , ' {$lname} ' , ' {$email} ' , ' {$pswrd} ' )");
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Signup</title>
<meta charset="utf-8">
<meta name="description" content="description of webpage">
<meta name="keywords" content="keywords go here">
<meta name="author" content="amsadler">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/signup.css">
<link rel="index" href="index.php">
<link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>
<div class="header">
<div id="logo">
<a href="index.php"><img src="img/logo.png" alt="logo" title="blah blah"/></a>
</div>
</div>
<div id="signupform">
<form method="post"><br>
<input type="text" id="fname" name="fname" placeholder="First name">
<input type="text" id="lname" name="lname" placeholder="Last name"><br><br>
<input type="text" id="email" name="email" placeholder="Email address">
<input type="password" id="pswrd" name="pswrd" placeholder="Password"><br><br>
<input id="button" type="submit" value="Submit">
</form>
</div>
<?php
include ("inc/footer.php");
?>
</body>
</html>