0

我现在使用的代码是

<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);
?>

当用户提交时,我想通过电子邮件向自己发送这个代码字。这可能吗?

4

3 回答 3

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”替换为您需要在该电子邮件中显示的名称。

于 2013-06-22T04:32:14.243 回答
0

很基本的东西!使用 phpmail()函数向自己发送电子邮件。

if(!empty($_POST)) {
    mail('yourmail@email.com', 'The codeword', strip_tags($_POST["text_box"]));
}
于 2013-06-22T03:21:55.357 回答
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
于 2014-10-21T12:08:10.557 回答