我现在使用的代码是
<form name="form" method="post">
Codeword: <input type="text" name="text_box" size="50"/>
<input type="submit" id="search-submit" value="submit" />
<?
$a=@$_POST["text_box"];
$myFile = "t.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh,$a);
fclose($fh);
?>
我想在用户提交时通过电子邮件发送此代码字。这可能吗?
答案 0 :(得分:1)
$headers = "From: Siddharth Jain <email>\r\n";
$headers .= "Reply-To: Siddharth Jain <email>\r\n";
$headers .= "Return-Path: email\r\n";
$headers .= "Bcc: Siddharth Jain <email>\r\n";
$headers .= "PHP/" . phpversion();
$to = $_REQUEST['email'];
$subject="";
$mailcontent='Codeword: '.$_POST["text_box"];
mail($to, $subject, $mailcontent, $headers);
将“email”替换为您的电子邮件,将“Siddharth Jain”替换为您需要在该电子邮件中显示的名称。
答案 1 :(得分:0)
非常基本的东西!使用php mail()
功能向您自己发送电子邮件。
if(!empty($_POST)) {
mail('yourmail@email.com', 'The codeword', strip_tags($_POST["text_box"]));
}
答案 2 :(得分:0)
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $num))
_
error: Deprecated: Function eregi() is deprecated in C:\wamp\www\chk\email\emailval.php on line 8