Mail form to random email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dwatson
Forum Newbie
Posts: 1
Joined: Fri Apr 27, 2007 11:34 am

Mail form to random email

Post by dwatson »

Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Help if you can. I am wanting to have the user fill in their e-mail address and then it randomely be sent to one of the 3 e-mail addresses. I have tested, Googled and pulled out a few hairs to get this to work. I am a beginner programmer. Any help or suggestions would be greatly appreciated.

Contact Form.

Code: Select all

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="generator" content="Adobe GoLive" />
		<title>MySoulQuestions.com</title>
		<link href="css/basic.css" rel="stylesheet" type="text/css" media="all" />

	</head>

	<body>
		<div id="cont">
		<div id="header"></div>
		<div id="content">
			<form action="process.php" method="post"> 
				<p>To contact us or for more information please enter your e-mail address.</p>
				<p><input type="text" name="Emailadd" size="40"></p>
				<p><input type="submit" name="Submit" /><input type="reset" /></p>
			</form>

				
			
			</div>
		</div>
	</body>

</html>
process.php

Code: Select all

<?php 

$email=array(); 
$email[0]="davidnwatson@yahoo.com"; 
$email[1]="dwatson@dcso.nashville.org"; 
$email[2]="lamandafwatson@yahoo.com"; 

//send email 
$email = $email[rand(0, count($email))]; 
$subject = "MySoulQuestions: Response Form"'] ; 
$message = $_REQUEST['mes'] ; 
mail($email, "Subject: $subject", 
$message, "From: $emailadd" ); 
echo "Success"; 
} 
} 
else 
{ 
echo "Error"; 
} 
?>
David Watson


Jcart | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I assume you are getting a parse error.. look at the syntax highlighter, it should be very obvious where your error lies.
Post Reply