PDA

View Full Version : مشکل با ارسال ایمیل و Cookie



ماهان مقدم
پنج شنبه 29 اسفند 1387, 20:26 عصر
آقا مشکل این کد من چیه ؟ این اسکریپت کارش باید ارسال ایمیل و ثبت ارسال شدن در کوکی باشه ولی اول در مورد setcookie ایراد میگیره و بعد هم اصلا ایمیلی نمیفرسته.


<html>

<head>
<title></title>
</head>

<body>

<?php

$to = "info@df-team.ir";
$from = "Opinion Sender";
$from_header = "From: $from";
$subject = "Opinion";
$contents = "Pooyan: " . $_POST["P1"] . "Mostafa: " . $_POST["P2"] . "Mojtaba: " . $_POST["P3"] . "Mahan: " . $_POST["P4"];
$Co = $_COOKIE["OP"];
if($Co == "Passed"){
echo("You can't send opinion becuase you passed this action.");
}
else {
if($contents != "")
{
//send mail - $subject & $contents come from surfer input
mail($to, $subject, $contents, $from_header);
// redirect back to url visitor came from
echo("You'r opinion is sent !. Now you can turn to you'r page. Bye !");

}
else
{
print("<HTML><BODY>Error, no comments were submitted!");
print("</BODY></HTML>");
}
}

if($Co != "Passed"){
setcookie("OP", "Passed", time()+3600);
}


?>

</body>

</html>

__ziXet__
پنج شنبه 29 اسفند 1387, 21:27 عصر
تبع setcookie رو بیار بالای echo

TheMohammad
پنج شنبه 29 اسفند 1387, 21:40 عصر
فکر کنم اینطوری بشه :



<?php
ob_start();
?>
<html>

<head>
<title></title>
</head>

<body>

<?php

$to = "info@df-team.ir";
$from = "Opinion Sender";
$from_header = "From: $from";
$subject = "Opinion";
$contents = "Pooyan: " . $_POST["P1"] . "Mostafa: " . $_POST["P2"] . "Mojtaba: " . $_POST["P3"] . "Mahan: " . $_POST["P4"];
$Co = $_COOKIE["OP"];
if($Co == "Passed"){
echo("You can't send opinion becuase you passed this action.");
}
else {
if($contents != "")
{
//send mail - $subject & $contents come from surfer input
mail($to, $subject, $contents, $from_header);
// redirect back to url visitor came from
echo("You'r opinion is sent !. Now you can turn to you'r page. Bye !");

}
else
{
print("<HTML><BODY>Error, no comments were submitted!");
print("</BODY></HTML>");
}
}

if($Co != "Passed"){
setcookie("OP", "Passed", time()+3600);
ob_flush();
}


?>

</body>

</html>

ماهان مقدم
جمعه 30 اسفند 1387, 11:09 صبح
ممنون دوستان کمکتون مشکلم رو حل کرد. خیلی ممنون.