473,385 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

"Contact Us" Form

Anyone know how to write PHP that can take values that a user inputs into a form on a webiste and the e-mail those values to myself. In other words how do i write PHP code for a Contact Us Form?
Dec 24 '06 #1
7 2149
ronverdonk
4,258 Expert 4TB
What is your game here? You had the same question answered in the HTML forum http://www.thescripts.com/forum/thread578591.html and you were shown (by me) a PHP script that does exactly that! After that post there has been a full discussion in the HTML forum.

You are DOUBLE POSTING!
What is the reason you post the same question here?? Look at the mentioned reply-post and use it.

When you have a problem with it, state your problem, but don't start another new discussion!

Ronald :cool:
Dec 24 '06 #2
the ones posted there do not work, and ppl told me to move it to the PHP section, so I did. Also I'm trying to figure out but no one has posted anything for the past 3 days. My problem right now is really only about the PHP part, yet another reason why I started a new discussion.

So sorry if i made you mad, I didnt mean to its just that I need to get this done ASAP and I need some help.
Dec 24 '06 #3
Here is how I have done it.

First the form code:

[php]
<form action="email.php" method="post">
Name<br><input type="text" name="username" size="50">
<p style="text-align: center; font-family:arial, verdana, lucida, helvetica, sans-serif;font-size: 16px">
Email Address<br><input type="text" name="useraddr" size="50">
<p style="text-align: center; font-family:arial, verdana, lucida, helvetica, sans-serif;font-size: 16px">
Comment<br>
<textarea name="comments" cols="50" rows="20"></textarea><br>
<input type="submit" value="Send Comment">
</form>
[/php]

And then the code that is executed when you click on "Send Comment":

[php]
<?php

$comments = $_POST['comments'];
$username = $_POST['username'];
$useraddr = $_POST['useraddr'];

$to = "destination@domain.com";
$re = "Website Comment Form";
$msg = $comments;
$headers = 'From: ' . $username . ' <' . $useraddr . '>' . "\r\n" .
'Reply-To: ' . $username . ' <' . $useraddr . '>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail( $to,$re,$msg,$headers );

?>

<html>
<head><title>Messsage Received</title></head>
<body>
<center><h3 class=h16>Thank You For Your Comments</h3></center>
<p>
<center>Message received from <?php echo( $username ); ?>
<br>
Reply to <?php echo( $useraddr ); ?></center>
</body>
</html>
[/php]

This is very basic but has worked for me. I need to beef it up with Captcha so bots can't exploit it
Dec 24 '06 #4
Atli
5,058 Expert 4TB
Would I be wrong to assume you'd need an active mail service on you server to use the main() function?
Dec 25 '06 #5
ronverdonk
4,258 Expert 4TB
What do you mean by "an active mail service"? You can install your own mail server or use an existing one. The latter is usually used. Only requirement is that your ISP allows you to send out mail (usually via port 25).

Ronald :cool:
Dec 25 '06 #6
Atli
5,058 Expert 4TB
Yea thats what I thought,
not really sure wtf I was thinking when I wrote that :-P
Dec 25 '06 #7
Here is how I have done it.

First the form code:

[php]
<form action="email.php" method="post">
Name<br><input type="text" name="username" size="50">
<p style="text-align: center; font-family:arial, verdana, lucida, helvetica, sans-serif;font-size: 16px">
Email Address<br><input type="text" name="useraddr" size="50">
<p style="text-align: center; font-family:arial, verdana, lucida, helvetica, sans-serif;font-size: 16px">
Comment<br>
<textarea name="comments" cols="50" rows="20"></textarea><br>
<input type="submit" value="Send Comment">
</form>
[/php]

And then the code that is executed when you click on "Send Comment":

[php]
<?php

$comments = $_POST['comments'];
$username = $_POST['username'];
$useraddr = $_POST['useraddr'];

$to = "destination@domain.com";
$re = "Website Comment Form";
$msg = $comments;
$headers = 'From: ' . $username . ' <' . $useraddr . '>' . "\r\n" .
'Reply-To: ' . $username . ' <' . $useraddr . '>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail( $to,$re,$msg,$headers );

?>

<html>
<head><title>Messsage Received</title></head>
<body>
<center><h3 class=h16>Thank You For Your Comments</h3></center>
<p>
<center>Message received from <?php echo( $username ); ?>
<br>
Reply to <?php echo( $useraddr ); ?></center>
</body>
</html>
[/php]

This is very basic but has worked for me. I need to beef it up with Captcha so bots can't exploit it
So I make this two different pages. One for the form and the other is with Message Recieved page?
Dec 25 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Jason | last post by:
I'm struggling with this email code and I'm not php freak since I'm starting to learn php stuff. Could use some help... It seems that I get too many parse errors all over and cannot figure went...
4
by: Al Dykes | last post by:
I'm going to be collecting lots (a few thousand) email addys. Each of these people will be interested in recieving mail on one or more topics, with an open ended and growing number of topics....
17
by: Serge Fournier | last post by:
I would like to access the "contact" data in Outlook Express. Which reference do I have to use ? (I was thinking at "Office"). Thanks for any help
2
by: Matt | last post by:
delicious has a bookmark you can add to your toolbar of this form:...
1
by: H5N1 | last post by:
hi there the topic says it all. I have a outer join select statement in tableadapter that populates GridView, I want to make it updatetable, so I need to provide an update command for table...
25
by: popnbrown | last post by:
Hey umm how do you write a form that e-mails to you? I so far have created a form and some labels and textboxes Here is the code: <form name="contact" id="contact" method="put" action"#">...
1
by: kang jia | last post by:
how can i do contact us page? use mail function ??hmm.. but when i click "contact us" navigation. it will link the mailbox. how to do this linkage? i am quite new to PHP, maybe this problem seems...
14
by: confusedfusion | last post by:
Not sure how many form submissions that have been lost over the years before I started but the company has a contact form that the required fields when validation fails the error message is going...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.