0

我一直在寻找答案几个小时,并尝试了这些板和其他板的多种解决方案,但我仍然找不到答案。

我真的只想通过电子邮件从表单中接收复选框数据。

这是来自 dibs.php 的相关代码:


<form action="mailer.php" method="post" name="form1" id="form1" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue">


a004 <input type="checkbox" name="dibs[]" value="a004"><br />

z004 <input type="checkbox" name="dibs[]" value="z004"><br />

m003 <input type="checkbox" name="dibs[]" value="m003"><br />


<p>your e-mail address:</p>

<input name="from" type="text" id="from" style="padding:2px; border:1px solid #666666; width:180px; height:12px;" value="<?php echo $_GET['from'];?>">

<input type="hidden" name="subject" value="shoe dibs">

<p>please retype the image below into the box:</p>

<input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #666666; width:180px; height:12px;">

<img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" >


<!-- if the variable "wrong_code" is sent from previous page then display the error field -->

<?php if(isset($_GET['wrong_code'])){?>

<div style="border:1px solid #666666; background-color:#990000; color:#FFFFFF; padding:2px; width:280px;"><b>WRONG VERIFICATION CODE</b></div><br> 

<?php ;}?>

<input name="submit" type="submit" style="margin-top:10px; display:block; border:1px solid #666666; width:100px; height:20px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; color="#666666;" value="send your dibs">

</form>

以及来自 mailer.php 的代码:


<?php

// load the variables form address bar
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$from = $_REQUEST["from"];
$verif_box = $_REQUEST["verif_box"];

foreach($_POST["dibs"]  as  $value)  {
$dibs .= "$value\n";
}


// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$from = stripslashes($from); 

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("email@mydomain.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
} else {
// if verification code was incorrect then return to contact page and show error
header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<head>

我在结果页面上收到“无效参数”错误消息,除了发件人的 IP,我的电子邮件中没有任何内容。

我确定我将 foreach 代码放在了错误的位置,但出于所有意图和目的,我是 PHP 处女。这是别人的基本代码。

非常感谢。

4

0 回答 0