/    Sign up×
Community /Pin to ProfileBookmark

E-Mail Notification?

I have a simple contact for that writes input to a database, and then another page that I can go to, to check the output. Is there some code I can add to my contactinfo.php file to e-mail me when somebody adds something to the db? It doesn’t matter if the e-mail doesn’t contain the info just entered, I would just like to have notification when somebody enters data into the contact form. Here’s my code:

HTML

[CODE]
<form action=”contactinfo.php” method=”post”>
Name:<input type=”text” name=”vName” size=”30″><br>
E-Mail Address:<input type=”text” name=”vEmail” size=”30″><br>
<input class=”send” type=”submit” value=”Send Away!” />
</form>
[/CODE]

contactinfo.php

[CODE]
<?

mysql_connect(“$host”, “$user”, “$password”) or die(mysql_error());

mysql_select_db(“$database”) or die(mysql_error());

$name=$_POST[‘vName’];
$email=$_POST[‘vEmail’];

mysql_query(“INSERT INTO users
(name, email) VALUES(‘$name’, ‘$email’) “)
or die(mysql_error());

echo “<h1>Thank You!</h1><br>”;
echo “<a href=’index.html’>Back home</a>”;

?>
[/CODE]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@TJ111Aug 27.2007 — Just use PHP's mail function. Something like this doesn't even really require a database at all really, except for logging purposes. Here's an example for you.
[code=php]
$msg = "Name: $namen";
$msg .= "Email: $emailn";
$msg .= "nnn-----------------------n";
$msg .= "This is an automated message from my website. I could put whatever I wanted in here.";

//Mail paramaters are: address to email to, subject line, message, addition headers(optional), extra paramaters (optional)
mail ("[email protected]", "Contact Information", $msg);
[/code]
×

Success!

Help @mikegreenia_com spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...