Can't get my head around this at all. It works fine when testing locally but won't work on my server! All it is is a basic form script:
PHP Code:
<?php
#######################################################################
//
//
//
//
#######################################################################
// send message via email and display results on contact page
if (($_POST['contactSend']) || ($_POST['quickSend'])) {
// set error variable for each field to use as errorCode
// detect whether frm-quick was submitted
$error = array ();
if ($_POST['quickSend']) {
$name = $_POST['quickName'];
$email = $_POST['quickEmail'];
$emailRep = $_POST['quickEmailRep'];
$message = $_POST['quickMessage'];
} else {
$name = $_POST['contactName'];
$email = $_POST['contactEmail'];
$emailRep = $_POST['contactEmailRep'];
$message = $_POST['contactMessage'];
}
// email headers
$subject = 'Enquiry';
$mailEmail = 'pealo86@gmail.com'; // who will receive the email
$mailSender = 'From: ' . $name . '<' . $email . '>'; // who is sending the email
// check valid and no null values in fields
if (!$name) {
$error[] = 'name';
}
// check email
if ((!preg_match ('#^[^@]+@([a-z0-9\-]+\.)+[a-z]{2,4}$#', $email) || ($email == NULL))) {
$error[] = 'email';
}
// check email matches only if email is valid
if (($errorEmail == 0) && ($email != $emailRep)) {
$error[] = 'emailRep';
}
// check message exists
if (!$message) {
$error[] = 'message';
}
//default message
$errorCount = count ($error);
if ($errorCount == 0) {
$mailSend = mail ($mailEmail, $subject, $message, $mailSender);
// process error
if (!$mailSend) {
$error[] = 'server';
} else {
// mail sent successfully
echo '
<div id="frm-pop">
<div>';
echo '<p class="highlight">';
echo "Thankyou for your enquiry. We'll get back to you as soon as possible.</p>
</div>
</div>";
}
} else {
// echo error message if unsuccessul
// declare warnings
$warning = array ('name' => 'You did not enter your name',
'email' => 'You must enter a valid email address',
'emailRep' => 'Your two entered email addresses do not match',
'message' => 'You did not enter a message',
'server' => 'There was a problem processing your message. Please try again');
echo '
<div id="frm-pop">
<div>
<p class="highlight">Sorry but there ';
switch ($errorCount) {
case 1:
echo 'was ' . $errorCount . ' error ';
break;
default:
echo 'were ' . $errorCount . ' errors ';
}
echo ' in your details. Please ' .
'review your entries.</p>
<ul class="list bullet">';
foreach ($error as $value) {
echo '<li>' . $warning[$value] . '</li>';
}
echo '</ul>
</div>
</div>';
}
}
?>
The script just cannot seem to put whatever is in the $_POST variables into another variable, such as this line:
PHP Code:
$name = $_POST['quickName'];
If I echo '$name', nothing is output. But if I echo '$_POST['quickName'];' then the value appears on screen!
I've double checked to make sure that all of the fields are named correctly in my HTML document also.
I even cut out all of the code at the start so that it started with something like:
PHP Code:
$name = $_POST['quickName'];
$email = $_POST['quickEmail'];
$emailRep = $_POST['quickEmailRep'];
$message = $_POST['quickMessage'];
echo $name;
No luck again.
And even more confusing, I originally added these lines when trying to find the problem:
PHP Code:
if ($_POST['quickSend']) {
$name = $_POST['quickName'];
$email = $_POST['quickEmail'];
$emailRep = $_POST['quickEmailRep'];
$message = $_POST['quickMessage'];
echo '1234';
exit;
} else {
And it brings up this error:
Quote:
|
Parse error: syntax error, unexpected '}' in /home/inspin/public_html/freshbeat/concept/valleytheatre.co.uk/26032010/script/contact/process.php on line 85
|
And all that reads on line 85 is this:
PHP Code:
<p class="highlight">Sorry but there ';
!??!?!?!?!
Could it be the way my server is configured? As I say, the script works fine locally. What's even more confusing is the way I have very similar scripts running on my same hosting account with none of these issues!
Many thanks to anyone who can help.