So I was starting to think I know what I'm doing and I've written this code but there are errors I don't understand.
The PHP takes details from a form on another page, check the required fields aren't empty and then sends a couple of emails.
The problems, I think, start when I try to define the messages of the emails. $message1 = a load of really complicated mixed up code.
Here's whole of the code:
PHP Code:
<?php
$name = $_REQUEST['name'];
$company = $_REQUEST['company'];
$position = $_REQUEST['position'];
$tel = $_REQUEST['telephone'];
$email = $_REQUEST['email'] ;
$city = $_REQUEST['city'];
$state = $_REQUEST['state'];
$country = $_REQUEST['country'];
$interest = $_REQUEST['interest'];
$contactType = $_REQUEST['contactType'];
$timeTable = $_REQUEST['timeTable'];
$message = $_REQUEST['message'];
$site = $_REQUEST['site'];
//set country as Brazil is it is not anything else
if ($_REQUEST['country'] == '')
{$country = 'Brasil';}
else
{$country = $_REQUEST['country'];}
// if any of the required fields are blank, redirect to an error message on original page
if ($name =="" or $company =="" or $position=="" or $tel=="" or $email =="" or $city=="" or $state=="" or $interest=="")
{
//...and redirect to an error message.
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'form.php?required=show';
header("Location: http://$host$uri/$extra");
exit;
}
//otherwise send the emails and a redirect to a success note
else
{
//define subjects and messages for each of the emails
$subject1 = 'Fale Conosco - E-mail do Site';
$subject2 = 'Contato com a Torema Brasil';
//here is where the problems start!
//set the message to be sent to the Torema
$message1 = 'E-mail do Site da Pagina: Fale Conosco\r\n\r\n'
'Nome: '.$name.'\r\n'
'Cargo: '.$company.'\r\n'
'Empresa: '.$company.'\r\n'
'Cidade: '.$city.' / '.$state.
//if the country is anything other than Brasil write it
if ($country=='Brasil')
{ echo '\r\n\r\n';}
else
{ echo $country'\r\n\r\n';}
'Intressa: '.$interest.'\r\n'
//if there is a message write it
if ($message=='')
{ echo '\r\n';}
else
{ echo 'Mensagem: '.$message.'\r\n';}
'Deseja Contato Por: '.$contactType.'\r\n'
'Horario de Contato: '.$timeTable.'\r\n\r\n'
'Fone: '.$tel.'\r\n'
'E-mail: '.$email.'\r\n'
'Site: www.'.$site.'\r\n';
//set the thankyou message to be sent to user
$message2 = 'Obrigado por o seu mensagem à Torema Brasil \r\n\r\n'
'A gente vai ver blah blah... \r\n\r\n'
'Support, Torema Brasil. \r\n\r\n';
//send the email to Torema
mail("webmaster@torema.com.br", $subject1, $message1, "From: $email" );
//.send the email to the user
mail('<'.$name.'>'. $email, $subject2, $message2, "From: no-reply@torema.com.br"); */
//redirect to the original page and show a success note.
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'form.php?send=yes';
header("Location: http://$host$uri/$extra");
exit;
}
?>
An error turns up for line 49 which is the second of these two:
PHP Code:
$message1 = 'E-mail do Site da Pagina: Fale Conosco\r\n\r\n'
'Nome: '.$name.'\r\n'
Yet, I am sure it's not the only fault. If anyone can suggest what's wrong with it and how it could be improved that would awesome.
Peace
dog
Bookmarks