0

I can't seem to find the error from my code? Quite confused as to why this is not working, any help would be amazing! :) Line 31 is the line with the closed bracket for the last echo.

<?php

$con = mysqli_connect('127.0.0.1','root','');

if (!$con)
{
    echo 'No connection to the local server';
}

if (mysqli_select_db($con, "info"))
{
    echo 'No connection to database';
}

$Name = (isset($_POST ['Full_Name']));
$MobileNumber = (isset($_POST ['Mobile_Number']));
$Email = (isset($_POST ['email']));
$Address = (isset($_POST ['address']));
$PostCode = (isset($_POST ['Post_Code']));
$Interests = (isset($_POST ['interests']));

$sql = "INSERT INTO info (Name, Mobile Number,Email,Address,Post Code,Interests) VALUES ('$Name', '$MobileNumber','$Email','$Address','$PostCode','$Interests')";

if (mysqli_query($con,$sql))
{
    echo 'Details not inserted correctly';
}
else
{
    echo 'Thank you for your details, we will be in touch, you will be redirected in 5 seconds';
}

header("refresh:5; url=contact.html");

?>

Below is my form code

form action ="datanew.php" method = "post">

Name: <input type = "text" name = "Full Name">
MobileNumber: <input type = "interger" name = "Mobile Number">
Email: <input type = "text" name = "Email">
Address: <input type = "text" name = "Address">
PostCode: <input type = "text" name = "Post Code">
Interests: <input type = "text" name = "Interests">
<input type = "submit" value = "Enter">
</form>
Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
dave
  • 13
  • 3
  • seems valid probably one of the form inputs, your not sanatising them for db input –  Feb 28 '17 at 21:22
  • I've added my form code above, do you see any coding errors? – dave Feb 28 '17 at 21:28
  • itswhat is put in the form fields that may be an issue –  Feb 28 '17 at 21:28
  • Have you tried removing the space in `$_POST [...`? Also, not sure if you are aware, but all your values are going to be "True" or "False" since you set all your variables to `isset(...)`... – nibnut Feb 28 '17 at 21:30
  • Yeah I just removed the isset() and yeah I just tried that still comes up with the same error.. :L – dave Feb 28 '17 at 21:36

0 Answers0