Here is my "index.php" code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "UTF-8">
<meta name = "viewport" content="width=device-width,initial-scale=1.0">
<title>Registration Form</title>
</head>
<h1>Blood Donation Camp </h1>
<body bgcolor="FBB917">
<div><h2>Registration Form</h2></div>
<form action='connect.php' method="POST">
<label for="user">Name:</label><br>
<input type="text" name="name" id="name" required/> <br><br>
<label for="email">Email:</label><br>
<input type="email" name="email" id="email" required/> <br><br>
<label for="phone">Phone:</label><br>
<input type="text" name="phone" id="phone" required/> <br><br>
<label for="bgroup">Blood Group:</label><br>
<input type="text" name="bgroup" id="bgroup" required/> <br><br>
<input type="submit" name="submit" id="submit">
</form>
</body>
</html>
Here is my "connect. php" code:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit']))
{
$conn = mysqli_connect('localhost','root','','test1',3307) or die("Connection Failed!" .mysqli_connect_error());
if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['bgroup']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$bgroup=$_POST['bgroup'];
$sql="INSERT INTO 'users' ('name','email','phone','bgroup') VALUES ('$name','$email','$phone','$bgroup')";
$query = mysqli_query($conn,$sql);
if($query)
{
echo "Entry Successful! <br>";
}
else
{
echo "Error Occurred! <br>";
}
}
}
?>
I change my default port of mysql database as 3307 and also change default port of Apache Web Server as 81. But I think there is no connection error as "Connection failed!" message doesn't show up. Only "Error Occurred!" message is appeared!