一个是“在线E-mail 发送”的代码,共两个文件 form.html 和 contactmail.php
一个是可以 “变换图片的登录验证码” 代码,共两个文件 authimg.php 和 authpage.php
需要解决的:
把这两个整合在一起,当在线发送Email 的时候,必须按照图片上的显示正确数字填入验证码,才可以正常提交信息,发送邮件....
我是不太懂的,在这里谢谢大家了!
form.html 包含的全部代码
<u>Email Form</u> - Please be specific.</font>
<form method="post" action="contactmail.php" name="form2"><font size="2">
<B><BR>Your Name:</B><br><input type="TEXT" name="name" width="28"><BR><br>
<B>Your Email Address:</B><br><input type="TEXT" name="email" width="28"><BR><BR><BR>
<B>Department</B>
<SELECT NAME="dep">
<OPTION VALUE="support">Please Choose
<OPTION VALUE="webmaster">WebMaster
<OPTION VALUE="support">Support
<OPTION VALUE="sales">Sales
<OPTION VALUE="technical">Technical
</SELECT> <font size="1"><font color="red">*</font>Defaults to Support</font><BR><BR>
<BR><font size="2"><B>Query</B></font><BR><TEXTAREA NAME="reason" ROWS=10 COLS="45"></TEXTAREA><br><BR>
<input type="SUBMIT" value="Submit">
<input type="reset" value="Reset"></font>
</form>
contactmail.php 包含的全部代码:
<?php
// ##########################################
// Set the below value to your email address
$to = "you@yourdomain.com";
// ##########################################
// EDIT BELOW AT YOUR OWN RISK
function check_email($email){
if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email)){
return TRUE;
} else {
return FALSE;
}
}
$poster = $_POST['name'];
$postemail = $_POST['email'];
$department = $_POST['dep'];
$postreason = $_POST['reason'];
if (!check_email($postemail)) {
echo "<META HTTP-EQUIV=Refresh CONTENT=3;URL=javascript:window.history.back(-1)>";
$messege = "<center>
Email address<br><u> $postemail </u><br><FONT COLOR=\"#990000\">NOT VALID</FONT>
<br>Taking you back now... ";
} else {
$messege = "Thank you $poster for your submission.<BR> We will get back to you within the next 24 hours.";
$subject = "Contact Submission";
$message = "
<html>
<head>
<title>Contact Submission</title></head>
<body>
<b>To Department</b> -- $department <br>
<b>Poster</b> -- $poster <br>
<b>Poster Email</b> -- $postemail <br>
<b>Poster Submitted:</b> <br><br>
$postreason </body></html>";
$headers?= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: Contact Submit <$to> \r\n";
$headers .= "From: $postemail <$postemail>\r\n";
mail($to, $subject, $message, $headers);
}
echo "$messege";
?>
authimg.php 包含的全部代码
<?php
//生成验证码图片
Header("Content-type: image/PNG");
srand((double)microtime()*1000000);
$im = imagecreate(62,20);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,68,30,$gray);
while(($authnum=rand()%100000)<10000);
//将四位整数验证码绘入图片
imagestring($im, 5, 10, 3, $HTTP_GET_VARS['authnum'], $white);
for($i=0;$i<300;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand
(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);
?>
authpage.php 包含的全部代码
<?php
srand((double)microtime()*1000000);
//验证用户输入是否和验证码一致
if(isset($HTTP_POST_VARS['authinput']))
{
if(strcmp($HTTP_POST_VARS['authnum'],$HTTP_POST_VARS['authinput'])==0)
echo "验证成功!";
else
echo "验证失败!";
}
//生成新的四位整数验证码
while(($authnum=rand()%10000)<1000);
?>
<form action=authpage.php method=post>
<table>
请输入验证码:<input type=text name=authinput style="width: 80px"><br>
<input type=submit name="验证" value="提交验证码">
<input type=hidden name=authnum value=<? echo $authnum; ?>>
<img src=authimg.php?authnum=<? echo $authnum; ?>>
</table>
</form>