Labdien!
Tika izveidots html form. Form'ā ir 4 lauki: Vārds ($name), Email ($email), Tēma ($subject) un Ziņa ($msg). Mērķis: vēlos lai nospiežot Submit (Sūtīt), ziņa tiktu nosūtīta uz manu inbox e-mailu (
[email protected]). Ja kāds no laukiem netiek aizpildīts, attiecīgi jāatveras html failam "error.html", ja viss aizpildīts - "message_sent.html"
Izmantoju sekojošu php scriptu:
// Receiving variables
@$pfw_ip= $_SERVER['REMOTE_ADDR'];
@$name = addslashes($_POST['name']);
@$email = addslashes($_POST['email']);
@$subject = addslashes($_POST['subject']);
@$msg = addslashes($_POST['msg']);
// Validation
if (strlen($name) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($email) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($subject) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($msg) == 0 )
{
header("Location: error.html");
exit;
}
//Sending Email to form owner
$pfw_header = "From: $email\n"
. "Reply-To: $email\n";
$pfw_subject = "jobfinder";
$pfw_email_to = "
[email protected]";
$pfw_message = "Visitor's IP: $pfw_ip\n"
. "name: $name\n"
. "email: $email\n"
. "subject: $subject\n"
. "msg: $msg\n"
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header );
header("Location: message_sent.html");
?>
Pie form action norādīju ceļu uz šo php scriptu. Serveris atbalsta PHP. Aizpildot laukus, un, nospiežot Sūtīt, viss it kā ok - atveras html lapa "message_sent.html".
Problēma sekojoša: uz e-mail nepienāk ziņa (!).
Kur esmu pieļāvis kļūdu?