I asked for help about 3 days ago on this forum but contact has stalled, I’ve also got test.php to test connection to the database and test query to the database, they work as expected. Is there a typo or am i doing something wrong?
Here is the code so far:
<div class="morecontent_holders">
<div class="text1">
<form action="thankyou.php" method="post">
Name:<br>
<input type="text" name="u_name" required><br>
Email:<br>
<input type="email" name="u_email" required><br>
Subject:<br>
<input type="text" name="subj" required><br>
Message:<br>
<input type="text" name="message" required><br>
<input type="submit" value="Submit"><br>
</form>
</div>
</div>
Here is connection.php:
<?php
function Connect()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "responses";
// Create connection
$conn = new mysqli(servername, username, password, dbname) or die($conn->connect_erro$
return $conn;
}
?>
Here is thankyou.php:
<?php
require 'connection.php';
$conn = Connect();
/* skip testing for the POST array for now */
/* Prepare an insert statement */
$query = "INSERT INTO tb_cform (u_name, u_email, subj, message) VALUES (?,?,?,?)";
$stmt = $conn->prepare($query);
$stmt->bind_param("ssss", $_POST['u_name'], $_POST['u_email'], $_POST['subj'], $_POST[$
/* Execute the statement */
$stmt->execute();
if ($stmt->affected_rows > 0) {
echo "Thank You For Contacting Us <br>";
printf("rows inserted: %d\n", $stmt->affected_rows);
} else {
echo "Did not enter data";
}
/* close statement */
$stmt->close();
$conn->close();
?>
Any help would be gratefully appreciated thank you