Hi,
Im new to this forum (and PHP 🙂 and Im hoping someone here can help, please!
I've built a HTML form that uses PHP to connect to mySQL database. Everything is in the one php document and is working. Except that I cant get PHP to print to the page after the submit image has been clicked.
Here is the php part of the document:
<?php
include 'library/config.php';
include 'library/opendb.php';
if ($submit_x) {
$name = trim($_POST['txtName']);
$email = trim($_POST['txtEmail']);
$message = trim($_POST['mtxMessage']);
if(!get_magic_quotes_gpc())
{
$name = addslashes($name);
$message = addslashes($message);
}
if ($message != ""){
$message = "Name: $name\nEmail: $email\nComments: $message\n";
$extra = "From: $name\r\nReply-To: $email\r\n";
mail ("noone@nowhere.com", "Website Email", $message, $extra);
}
$query = "INSERT INTO guestbook (name, email, phone, message) " .
"VALUES ('$name', '$email', '$phone', '$message')";
mysql_query($query) or die('Error, query failed. ' . mysql_error());
header('Location: ' . $_SERVER['REQUEST_URI']);
exit;
}
I thought I could add another bit of php below the html form that checks if submit is clicked eg.
<? php
if (?submit_x){
print "thanks";
}
But this doesnt work I get cannot modify header errors.
Any help greatly appreciated!!
Mel