Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Email Forms - Name field
Old 10-17-2007, 10:07 AM Email Forms - Name field
pjb007's Avatar
Super Talker

Posts: 104
Location: UK
Trades: 0
I have had a look at this example PHP Form
http://www.w3schools.com/php/php_mail.asp

The example called PHP Mail Form (the second example on that page) sends an email almost exactly as I require it to.

However I tried to add a Name field and change the PHP to show the persons name rather than their email address in my email client.

However I can only get it to display the email address.

Is it possible to display the contents of the Name field here and keep the ability to click reply and reply to the person.
__________________
pjb007
pjb007 is offline
Reply With Quote
View Public Profile Visit pjb007's homepage!
 
 
Register now for full access!
Old 10-17-2007, 10:32 AM Re: Email Forms - Name field
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
PHP Code:
$to "someone@example.com";
$subject "Test mail";
$message "Hello! This is a simple email message.";
$name "your name";
$from "someonelse@example.com";
$headers "From: $name <$from>";
mail($to,$subject,$message,$headers);
echo 
"Mail Sent."
try that
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 10-17-2007, 11:14 AM Re: Email Forms - Name field
pjb007's Avatar
Super Talker

Posts: 104
Location: UK
Trades: 0
Thanks, great help!
__________________
pjb007
pjb007 is offline
Reply With Quote
View Public Profile Visit pjb007's homepage!
 
Old 10-17-2007, 04:42 PM Re: Email Forms - Name field
kfpoore's Avatar
Novice Talker

Posts: 13
Name: Kris Poore
Location: pensacola, florida
Trades: 0
Expanding on this question. My php skills can be considered novice at best.

I am also playing with this code from the w3schools website. Right now I'm researching authentication to prevent spam emails from coming through.

Ideally, I'd like to expand this form to allow the option of who to send an email to. For example, with some businesses, a drop-down menu is offered with several department emails listed. What I don't know, is where to start researching with this! I'm looking at if/else statements, but not sure if this is what I need to use to implement. Can anyone point me in the right direction? Thanks in advance.
kfpoore is offline
Reply With Quote
View Public Profile Visit kfpoore's homepage!
 
Old 10-17-2007, 04:54 PM Re: Email Forms - Name field
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by pjb007 View Post
Thanks, great help!
You're welcome ^^

Quote:
Originally Posted by kfpoore View Post
Expanding on this question. My php skills can be considered novice at best.

I am also playing with this code from the w3schools website. Right now I'm researching authentication to prevent spam emails from coming through.

Ideally, I'd like to expand this form to allow the option of who to send an email to. For example, with some businesses, a drop-down menu is offered with several department emails listed. What I don't know, is where to start researching with this! I'm looking at if/else statements, but not sure if this is what I need to use to implement. Can anyone point me in the right direction? Thanks in advance.
The best form-spam security would be the image verification and I have successfully used this on several forms.

The drop down is also quite simple.

For example

HTML Code:
<select name="departments">
<option selected>- Select Department -</option>
<option value="sales">Sales</option>
<option value="support">Support</option>
... etc etc
</select>
php after submitted:

PHP Code:

switch($_POST['department']) {

case 
"sales":
$department "sales@site.com";
break;


case 
"support":
$department "support@site.com";
break;

default:
$department "webmaster@site.com";
break;

}

mail($department"subject""message"headers here); 
edit: made a whoopsy .. fixed
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!


Last edited by Galaxian; 10-17-2007 at 05:00 PM..
Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 10-18-2007, 08:47 AM Re: Email Forms - Name field
kfpoore's Avatar
Novice Talker

Posts: 13
Name: Kris Poore
Location: pensacola, florida
Trades: 0
Well. Was I way off. :P Thanks for your help!
kfpoore is offline
Reply With Quote
View Public Profile Visit kfpoore's homepage!
 
Old 10-18-2007, 08:52 AM Re: Email Forms - Name field
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by kfpoore View Post
Well. Was I way off. :P Thanks for your help!

Not really!

Here is the same in if statements:

PHP Code:

if($_POST['department'] == "sales") {
$department "sales@site.com";
} elseif(
$_POST['department'] == "support") {
$department "support@site.com";
} else {
$department "webmaster@site.com";

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Reply     « Reply to Email Forms - Name field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30058 seconds with 12 queries