Hi all,
I wonder if someone can help me with the following as I cannot see where I'm going wrong.
In the header of my page I have the following PHP code:
<?php
empty($_POST['name']) ? $name='' : $name = $_POST['name'];
empty($_POST['phone']) ? $phone='' : $phone = $_POST['phone'];
empty($_POST['email']) ? $email='' : $email = $_POST['email'];
empty($_POST['state']) ? $state='' : $state = $_POST['state'];
empty($_POST['message']) ? $message='' : $message = $_POST['message'];
if(!empty($_POST['sbm']) && $_POST['sbm'] == 'true'){
$verif_box = $_REQUEST["verif_box"];
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
require_once 'includes/class.ext.mail.php';
$options = array(
'To' => 'info@mailaddress', /* Sets the To email address for the message */
'ToName' => '', /* Sets the From name of the message */
'From' => '', /* Sets the From email address for the message */
'FromName' => '', /* Sets the From name of the message */
'Subject' => 'Contact form', /* Sets the Subject of the message */
'Mailer' => 'mail', /* Method to send mail: ("mail", "sendmail", or "smtp") */
'Host'=> '', /* Sets the SMTP hosts. All hosts must be separated by a semicolon.
You can also specify a different port for each host by using this
format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").
Hosts will be tried in order. */
'Port' => 25, /* Sets the default SMTP server port */
'SMTPAuth' => false, /* Sets SMTP authentication. Utilizes the Username and Password variables. */
'Username' =>'', /* Sets SMTP username. */
'Password' => '', /* Sets SMTP password. */
);
$fields = array(
'Nome (your name)' => 'name',
'E.mail (E-mail address)' => 'email',
'Messaggio (Message)' => 'message'
);
$mail = new ExtMail($options);
if(empty($options['From'])) $mail->AddFromAddress($email,$name);
$mail->AddAddress($options['To'],$options['ToName']);
$Body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD></HEAD>
<BODY>';
$Body .= $_POST['m'].' '.$name.''.$name.'<br />';
if(!empty($phone))$Body .= 'phone: '.$phone.'<br />';
if(!empty($state))$Body .= 'state: '.$state.'<br />';
if(!empty($email))$Body .= 'email: '.$email.'<br />';
if(!empty($message))$Body .= 'message: '.$message.'<br />';
$AltBody = $_POST['name'].' '.$name.''.$name.'\n';
if(!empty($phone))$AltBody .= 'phone: '.$phone.'\n';
if(!empty($state))$AltBody .= 'state: '.$state.'\n';
if(!empty($email))$AltBody .= 'email: '.$email.'\n';
if(!empty($message))$AltBody .= 'message: '.$message.'\n';
$Body .= '</BODY></HTML>';
$mail->Body = $Body;
$mail->AltBody = $AltBody;
if($mail->Send()){
unset($_POST);
empty($_POST['name']) ? $name='' : $name = $_POST['name'];
empty($_POST['phone']) ? $phone='' : $phone = $_POST['phone'];
empty($_POST['state']) ? $state='' : $state = $_POST['state'];
empty($_POST['email']) ? $email='' : $email = $_POST['email'];
empty($_POST['message']) ? $message='' : $message = $_POST['message'];
}
setcookie('tntcon','');
} else {
$wrong_code = true;
}
}
?>
And then the contact form itself is as follows:
<?php if(isset($wrong_code)){?>
<div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;">Wrong verification code</div><br />
<?php }?>
<form id="form1" action="" name="form1" class="form" method="post">
<div class="row-box indent-top form">
<div class="row-box-1">
Enter Your Name:
<div class="indent-form"><input id="inp1" type="text" value="<?= $name ?>" name="name" /></div>
Enter Your Phone:
<div class="indent-form"><input id="inp2" type="text" value="<?= $phone ?>" name="phone" /></div>
Enter Your E-mail:
<div class="indent-form"><input id="inp3" type="text" value="<?= $email ?>" name="email" /></div>
Type Verification Image:
<div class="indent-form"><input id="inp4" type="text" value="" /></div>
</div>
<div class="row-box-2">
Enter Your Message:
<textarea id="text" cols="" rows="" name="message"><?= $message ?></textarea>
<a href="javascript:void(0);" class="link-1 form-link" onclick="document.getElementById('form1').reset()">Reset</a><a href="javascript:void(0);" class="link-1" onclick="document.getElementById('form1').submit()">Submit</a>
</div>
</div>
</form>
I need to sort the validation image; however, when I have tested the form it does not send a message and ideally I would like it to send a pop up message to say email successfully sent.
Can someone please help me in terms of what is wrong with the script.
Many thanks