Hi, I am using XAMPP and trying to put up a simple form. The index.php is
<form action='connect.php' method="POST">
<label for="user">Name: </label>
<input type='text' name='name' id="name" required/>
<br><br>
<label for="email">Email: </label>
<input type='email' name='email' id="email" required/>
<br><br>
<label for="phone">Phone: </label>
<input type='text' name='phone' id="phone" required/>
<br><br>
<input type='submit' name='submit' id='submit' />
</form>
The connect.php is
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit'])) {
echo 'submit button clicked';
$conn= mysqli_connect('localhost', 'root', '', 'my_software') or die("Connection Failed:" .mysqli_connect_error());
echo 'no connection error';
if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phone'])) {
$name= $_POST['name'];
$email= $_POST['email'];
$phone= $_POST['phone'];
echo 'Upto SQL';
$sql= "INSERT INTO 'user' ('name', 'email', 'phone') VALUES ('$name', '$email', '$phone')";
echo 'SQL Run';
$query = mysqli_query($conn,$sql);
echo 'query run';
if($query) {
echo 'Entry Successful';
} else {
echo 'Error, Entry Failed';
}
}
}
?>
There was no addition to the database. So I used echo to find what or where it is going wrong. It prints up to " SQL Run ". But still, no input to the database I created using phpMyAdmin or any error message indicating where I am doing it all wrong. Any help would be great.