I'm new in using PHP
here's my HTML
<html>
<head>
<link rel="stylesheet" type="text/css" href="design.css">
</head>
<form action="process.php" method="post">
<body>
Username: <input type="text" name="username" maxlength="45" ><br>
Password: <input type="text" name="password" maxlength="45"><br>
Confirm Password: <input type="text" name="password" maxlength="45"><br><br>
First Name: <input type="text" name="first_name" maxlength="45"><br>
Middle Name: <input type="text" name="middle_name" maxlength="45"><br>
Last Name: <input type="text" name="last_name" maxlength="45"><br>
Birthday: <input type="text" name="birthday" maxlength="45"><br>
E-Mail: <input type="text" name="email_add" maxlength="45"><br><br>
<input type="submit" value="SAVE" style="width: 120px;height: 25px;">
</body>
</form>
</html>
and here's my PHP
<?php
$con=mysqli_connect("localhost","root","","sampledb");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO account (username, password, confirm_pwd, first_name,
middle_name, last_name, birthday, email_add) VALUES
('$_POST[username]','$_POST[password]','$_POST[confirm_pwd]',
'$_POST[first_name]','$_POST[middle_name]','$_POST[last_name]',
'$_POST[birthday]','$_POST[email_add]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
Where did I go wrong? Can anyone tell me? Did I do something wrong? When I try to save it, it just redirects to process.php
, I checked the db but it didn't insert any data to the database.