PHP E-Mail Form Code

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

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP E-Mail Form Code

Post by Celauran »

Doesn't make any sense to me that var_dump wouldn't display any output.
mdeppa
Forum Newbie
Posts: 10
Joined: Wed Sep 28, 2011 1:38 pm

Re: PHP E-Mail Form Code

Post by mdeppa »

This link http://0349433.netsolhost.com/dates.html has the form with the var_dump inserted in code below.

Code: Select all

<?php

/* Subject and E-Mail Variables */

	$emailSubject = 'Date and Location Request';
	$webMaster = 'mdd1127@yahoo.com';
	
/* Gather Data Variables */

	$studentsnameField = $_POST['studentsname'];
	$parentsnameField = $_POST['parentsname'];
	$locationField = $_POST['location'];
	$highschoolField = $_POST['highschool'];
	$hearField = $_POST['hear'];
	$dayphoneField = $_POST['dayphone'];
	$eveningphoneField = $_POST['eveningphone'];
	$emailField = $_POST['email'];
	
	$body = <<<EOD
<br><hr><br>
Students Name: $studentsname <br>
Parents Name: $parentsname <br>
City / State: $location <br>
Nearest High School: $highschool <br>
How did you hear about the Workshops?: $hear <br>
Daytime Phone: $dayphone <br>
Evening Phone: $eveningphone <br>
E-Mail: $email <br>
EOD;

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
	var_dump($success);
	
/* Results rendered as html */

	$theResults = <<<EOD
<html>Code removed for easier viewing</html>
EOD;
echo "$theResults";

?>
Last edited by Benjamin on Wed Sep 28, 2011 6:07 pm, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP E-Mail Form Code

Post by Celauran »

View source after the form has been submitted. Very first line is bool(true). mail function completed successfully, meaning the problem is with your mail server.
mdeppa
Forum Newbie
Posts: 10
Joined: Wed Sep 28, 2011 1:38 pm

Re: PHP E-Mail Form Code

Post by mdeppa »

So everything looks to be working okay. I will check with Network Solutions to see if they can help resolve the issue. Thanks for all of your help.
Post Reply