I asked a question yesterday around this, but I have made some adjustments with my code. I am struggling now to get ANY enter to my Database.
HTML (person.html):
<body>
<form id="person" action="personuploader.php" method="post">
<table class="#">
<tr>
<th colspan="2">Test 2</th>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" id="email" name="email"> </td>
</tr>
<tr>
<td>Type:</td>
<td><input type="text" name="type"> </td>
</tr>
<tr>
<td>Cats:</td>
<td><input type="text" name="cats"> </td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Notify Me" name="submit">
</tr>
</table>
</form>
</body>
</html>
PHP (personuploader.php):
<?php
$con=mysqli_connect("?","?","?","?");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(isset($_POST['submit'])){
if(empty($_POST['email'] || empty($_POST['type']) || empty($_POST['cats']))
{
die("You need to fill in all the fields.");
}
$email = mysqli_real_escape_string($con, $_POST['email']);
$type = mysqli_real_escape_string($con, $_POST['type']);
$cats = mysqli_real_escape_string($con, $_POST['cats']);
$sql="INSERT INTO Persons (`email`, `type`, `cats`)
VALUES ('$email','$type','$cats')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
header("Location: http://domain.co.uk/"); exit();
} // end of if(isset($_POST['upload']
else{ echo ("You cannot do this operation from here."); }
mysqli_close($con);
?>
Whereas my previous PHP allowed the entries to populate the Database (open to SQL injection) I am getting no success whatsoever here nor any entries to the database, can someone point the error of my ways here?
Regards