Having some issues telling exactly where I am making an error from the php script below. It gets data via post from a HTML form. Then am trying some validations before inserting them into a database. Anyone spot anything?
<?php
if( isset( $_POST['submit_form'] ) )
{
validate_data($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = strip_tags($data);
$data = htmlspecialchars($data);
$data = mysqli_real_escape_string($data);
return $data;
}
$address = validate_data($_POST['name']);
$address = validate_data($_POST['address']);
$zipcode = validate_data($_POST['zipcode']);
$county = validate_data($_POST['county']);
$phone = validate_data($_POST['phone']);
$email = validate_data($_POST['email']);
$password = validate_data($_POST['password']);
$pwVerified = validate_data($_POST['pwVerified']);
//create connection
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO company (name, address, zipcode, county, phone, email, password, pwVerified )
VALUES
( '$name', '$address', '$zipcode','$county','$phone', '$email', '$password', '$pwVerified')";
if ($conn->query($sql) === TRUE) {
// echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}else
{ echo "there is a problem";}
include 'sign.php';
?>