使用简单的PHP代码发送文本框输入? [英] Email a textbox input using simple php code?

查看:463
本文介绍了使用简单的PHP代码发送文本框输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在使用的代码是

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

当用户提交时,我想向自己发送此代码字。这是可能的吗?

I would like to email myself this codeword, when a user submits. Is this possible?

推荐答案

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

将您的电子邮件和Siddharth Jain的电子邮件替换为您需要显示的名称电子邮件。

Replace "email" with your email and "Siddharth Jain" with the name you need to display in that email.

这篇关于使用简单的PHP代码发送文本框输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆