The page shows all the index and variables as errors.
All the codes looks ok to me but is not working. I have looked around community and checked some solutions but nothing.
This is the code:
<?php
$result="";
if($_POST['submit']){
if(!$_POST['name']){
$error="<h3>FORM NOT SUBMITTED (try again)</h3>Please enter your name.";
};
if(!$_POST['phone']){
$error.="<br>Please enter your phone no.";
};
if(!$_POST['address']){
$error.="<br>Please enter your address.";
};
if(!$_POST['pin']){
$error.="<br>Please enter your Pincode.";
};
if(!$_POST['date']){
$error.="<br>Please enter the Date.";
};
if(!$_POST['time']){
$error.="<br>Please enter the time.";
};
if($error){
$result='<div class="alert alert-danger alert-dismissible">'.$error.'</div>';
}
else{
if ( mail("rhinoaid@gmail.com", "Service Needed",
"Name: ".$_POST['name']."
Phone no: ".$_POST['phone']."
Address: ".$_POST['address']."
Pincode: ".$_POST['pin']."
Date: ".$_POST['date']."
Time: ".$_POST['time']
)) {
$done="<h3>FORM SUBMITTED SUCCESSFULLY</h3>Thank you! RHINOaid will contact you shortly.";
$result='<div class="alert alert-success">'.$done.'</div>';
};
};
};
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<form method="post" action="">
<?php echo $result; ?>
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name" placeholder="Enter Name" name="name" value="<?php echo $_POST['name']; ?>">
</div>
<div class="form-group">
<label for="Phone">Phone:</label>
<input type="number" class="form-control" id="phone" placeholder="Enter Phone no." name="phone" value="<?php echo $_POST['phone']; ?>">
</div>
<div class="form-group">
<label for="address">Address:</label>
<input type="text" class="form-control" id="address" placeholder="Enter Address/Venue" name="address" value="<?php echo $_POST['address']; ?>">
</div>
<div class="form-group">
<label for="pin">Pincode:</label>
<input type="number" class="form-control" id="pin" placeholder="Enter Pincode" name="pin" value="<?php echo $_POST['pin']; ?>">
</div>
<div class="form-group">
<label for="date">Date:</label>
<input type="date" class="form-control" id="date" placeholder="dd/mm/yy" name="date" value="<?php echo $_POST['date']; ?>">
</div>
<div class="radio">
<label><input type="radio" name="time" value="From 9am to 12pm">From 9am to 12pm</label>
</div>
<div class="radio">
<label><input type="radio" name="time" value="From 12pm to 5pm">From 12pm to 5pm</label>
</div>
<div class="radio">
<label><input type="radio" name="time" value="From 5pm to 9pm">From 5pm to 9pm</label>
</div>
<input type="submit" name="submit" class="btn btn-success btn-sm" value="submit">
<small>By submitting you agree to our <a href="tc.html">terms</a> and <a href="policy.html">policy</a></small>
</form>
</div>
</body>
</html>