home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

[PHP] Creating "if" Statement for Email Form

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2620
Discussions: 200,999, Posts: 2,380,006, Members: 246,368
Old August 7th, 2006, 01:17 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Cody's Avatar
 
Join Date: Oct 2001
Posts: 2,309
[PHP] Creating "if" Statement for Email Form

Hello! I have an e-mail form which takes the submitted form and sends an e-mail with it.

The code is below:

Code:
<?php

ini_set("SMTP","localhost");
ini_set("smtp_port","25");
ini_set("sendmail_from","fromaddy");

if(isset($_POST['submit'])) {

	$to = "toaddy";
	$subject = $_POST['name'] . ': ' . $_POST['drop_down'];

	$name_field = $_POST['name'];
	$email_field = $_POST['email'];
	$message = $_POST['message'];
	
	$body = "From: $name_field\nE-Mail: $email_field\nMessage:\n$message\n";

	echo "Your message has been sent! <br> <a href=\"http://www.waupunpubliclibrary.org/contactus.php\">Click Here to Go Back</a> ";
	mail($to, $subject, $body);
	
} else {
	echo "Error: What are you doing?";
}
?>
How would I add an "if" statement in this (I think that's what it's called), so that if the 'drop_down' field equals some specific string, it sets the $to address to something else?

Thank you!

Cody
Cody is offline   Reply With Quote
Old August 7th, 2006, 02:13 PM     #2 (permalink)
Member
 
Carl-cox-'s Avatar
 
Join Date: Nov 2002
Location: Kent England
Posts: 395
somethign like this

PHP Code:
if($_POST['drop_down'] == "Some String"){
$to="email1@email.com";
}else{
$to="email2@email.com";

Just replace $to = "toaddy"; with the statement above
__________________
http://www.coxeh.com
Carl-cox- is offline   Reply With Quote
Old August 8th, 2006, 07:28 PM     #3 (permalink)
Ultimate Member
 
Cody's Avatar
 
Join Date: Oct 2001
Posts: 2,309
Thanks. This works great. I appreciate it!
Cody is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem trying to connect "AT" form factory case to a atx motherboard spreeway General Tech Discussion 9 June 18th, 2004 12:39 AM
I never thought of "Scrubs" uniforms as a fashion statement. no1_vern IMO Community 7 January 23rd, 2004 07:02 PM
WTB: small form factor PC ("Shuttle") barebone crazyray Traders Forum: Buy, Sell, Trade 5 November 28th, 2003 09:28 PM
The Empire Strikes Back: MS calls on its Camp Followers to form "Community" Contra MegalosSkylaki General Tech Discussion 5 September 24th, 2002 05:51 PM
creating an SMTP email messsage via a web form DVNT1 Webmastering and Programming 6 March 6th, 2002 12:57 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3111)
‘Rogue’ or ‘Rouge’? (9)
Charges against non-tippers dropped.. (22)
Foxconn Blackops x48 MoBo (5)
Nvidia GTX 260 problem (14)
Delete an OS (18)
Laptop with wireless problem. (13)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (9)
windows vista security holes (19)
[F@H SPAM 11/16/09] ! 1/2 months to.. (41)
windows 7 problem (7)
Recent Discussions
add ram to existing (4)
Computer shutting down on its own (6)
EVGA 9800 gtx help with finding a goo.. (13)
"Documents and Settings" fo.. (7)
Delete an OS (18)
Outputing 1080p from my PC to my 720p.. (0)
panasonic dmr ez48veb recorder (0)
Need help getting speakers to work (2)
Nvidia GTX 260 problem (14)
Laptop with wireless problem. (13)
Point and Shoot Camera Suggestions. (9)
Is the PSU I received dead? (16)
FreeAgent drive software not x64 comp.. (1)
Intel 5100 AGN issues fixed yet? (28)
Foxconn Blackops x48 MoBo (5)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (41)
Print spooler problem (17)
Q9650 vs. Q9550 (2)
Desktop Calendar Application (2)
Looking for new motherboard (1)
soundmon.exe (8)
Jedi Academy Problem (3)
Can a page file be "too big".. (1)
Size after cutting 700Mb file is 2.5 .. (0)
windows vista security holes (19)


All times are GMT -4. The time now is 02:22 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28