The code I am using now is
<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);
Replace "email" with your email and "Siddharth Jain" with the name you need to display in that email.
Pretty basic stuff! Use the php mail()
function to send an email to yourself.
if(!empty($_POST)) {
mail('yourmail@email.com', 'The codeword', strip_tags($_POST["text_box"]));
}
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