I’m trying to run an SQL statement that inserts client data into a database, however the row is not being inserted into the database.
[php]
<?php
$mysql['con'] = mysqli_connect("xxxx", "xxxx", "xxxx", "xxxx"); ;
$companyname = mysqli_real_escape_string($mysql['con'], $_POST['companyname']);
$clientname = mysqli_real_escape_string($mysql['con'], $_POST['clientname']);
$email = mysqli_real_escape_string($mysql['con'], $_POST['email']);
$address = mysqli_real_escape_string($mysql['con'], $_POST['address']);
$postcode = mysqli_real_escape_string($mysql['con'], $_POST['postcode']);
$mobile = mysqli_real_escape_string($mysql['con'], $_POST['mobile']);
$phone = mysqli_real_escape_string($mysql['con'], $_POST['phone']);
$checkemail = mysqli_query($mysql['con'], "SELECT * FROM `clients` WHERE email='" . $email . "'");
if(mysqli_num_rows($checkemail) != 0)
{
echo "Error: Email already exists";
exit;
}
$query = mysqli_query($mysql['con'], "INSERT INTO `clients` (`clientname`, `companyname`, `email`, `address`, `postcode`, `mobile`, `phone`, `comment`) VALUES '" . $companyname . "', '" . $clientname . "', '" . $email . "', '" . $address . "', '" . $postcode . "', '" . $mobile . "', '" . $phone . "', 'No Comments.'");
if($query)
{
$checkemailtwo = mysqli_query("SELECT * FROM `clients` WHERE email='" . $email . "'");
while($rowtwo = mysqli_fetch_array($checkemailtwo))
{
$idtwo = $rowtwo['id'];
}
header("Location: " . $siteindex . "viewjobs.php?client=" . $idtwo . "&update=1");
}
else
{
echo "Something went wrong";
exit;
}
?>
[/php]
Any help would be greatly appreciated.