Reputation: 1
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?
Upvotes: 0
Views: 2522
Reputation: 1
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
Upvotes: 0
Reputation: 16989
Pretty basic stuff! Use the php mail()
function to send an email to yourself.
if(!empty($_POST)) {
mail('[email protected]', 'The codeword', strip_tags($_POST["text_box"]));
}
Upvotes: 0
Reputation: 68
$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.
Upvotes: 1