These are the errors I get on the cpanel when I try to test the email form on my website. The website form consists of a couple of fields to enter details such as (Name, Email, number and subject along with a message)
[19-Oct-2021 11:18:42 UTC] PHP Warning: Illegal string offset 'status' in contact.php on line 56
[19-Oct-2021 11:18:42 UTC] PHP Warning: Illegal string offset 'msg' in contact.php on line 57
[19-Oct-2021 12:28:25 UTC] PHP Warning: Illegal string offset 'status' in contact.php on line 55
[19-Oct-2021 12:28:25 UTC] PHP Warning: Illegal string offset 'msg' in contact.php on line 56
[19-Oct-2021 12:32:54 UTC] PHP Warning: Illegal string offset 'status' in contact.php on line 55
[19-Oct-2021 12:32:54 UTC] PHP Warning: Illegal string offset 'msg' in contact.php on line 56
Below is the PHP code that I have used but I'm unsure as to why I am still getting this error. Is anyone able to help me out here.
`<?php
/*
Variable
$dzName : Contact Person Name
$dzEmail : Contact Person Email
$dzMessage : Contact Person Message
$dzRes : response holder
$dzOtherField : Form other aditional fields
$dzMailSubject : Mail Subject.
$dzMailMessage : Mail Body
$dzMailHeader : Mail Header
$dzEmailReceiver : Contact receiver email address
$dzEmailFrom : Mail Form title
$dzEmailHeader : Mail headers
*/
$dzEmailTo = "gwcentre@gmail.com"; // Receiver Email Address "reciever@gmail.com"
$dzEmailFrom = "Website Contact";
function pr($value)
{
echo "<pre>";
print_r($value);
echo "</pre>";
}
#### Contact Form Script ####
if(!empty($_POST) && $_POST['dzToDo'] == 'Contact')
{
$dzName = trim(strip_tags($_POST['dzName']));
$dzEmail = trim(strip_tags($_POST['dzEmail']));
$dzMessage = strip_tags($_POST['dzMessage']);
$dzRes = "";
if (!filter_var($dzEmail, FILTER_VALIDATE_EMAIL))
{
$dzRes['status'] = 0;
$dzRes['msg'] = 'Wrong Email Format.';
echo json_encode($dzRes);
exit;
}
$dzMailSubject = 'Golf Club|Contact Form: A Person want to contact';
$dzMailMessage = "
A persone want to contact you: <br><br>
Name: $dzName<br/>
Email: $dzEmail<br/>
Message: $dzMessage<br/>
";
$dzEmailHeader = "MIME-Version: 1.0\r\n";
$dzEmailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$dzEmailHeader .= "From:$dzEmailFrom <$dzEmail>";
$dzEmailHeader .= "Reply-To: $dzEmail\r\n"."X-Mailer: PHP/".phpversion();
if(mail($dzEmailTo, $dzMailSubject, $dzMailMessage, $dzEmailHeader)==true)
{
$dzRes['status'] = 1;
$dzRes['msg'] = 'We have revieved your message successfuly.';
}
else
{
$dzRes['status'] = 0;
$dzRes['msg'] = 'Some problem in sending mail, please try again later.';
}
echo json_encode($dzRes);
exit;
}
#### Contact Form Script End ####'
Aucun commentaire:
Enregistrer un commentaire