Page 1 of 2

question about form processing script

Posted: Sat May 27, 2006 11:11 am
by Hazarrd
hawleyjr | 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]


Hi, I can't seem to debug this form processing script I wrote.  I'm fairly new to PHP.  It was working properly and then I did some tinkering and now it gives me an error on the line reading [b]"
if (empty($phone) || empty($email) || empty($dcotors_name) || empty($practice_name)) {"[/b].  Could anyone look at it and see what you can figure out?  Thanks a lot!

Code: Select all

<?php 
if(isset($_POST['submit'])) {
$phone = $_POST['phone'];
$email = $_POST['email'];
$doctors_name = $_POST['doctors_name'];
$practice_name = $_POST['practice_name']; 
$school = $_POST['school'];
//foreach($_POST['office_descr'] as $value1) { 
//$office_descr_msg .= "Office description: $value1\n";
//	}

$body = "
GENERAL INFORMATION


Practice Name: $practice_name\n
Doctor's Name: $doctors_name\n
Office Address: $officeaddress1\n  $officeaddress2\n
Phone: $phone\n
E-Mail: $email\n
Graduated from and year: $school\n
Website: $website\n

if (empty($phone) || empty($email) || empty($dcotors_name) || empty($practice_name)) {
	header("Location: http://www.opt-technology.com/incomplete_error.htm");
/*	$error_phone = "Phone\n";
	$error_email = "Email\n";
	$error_name = "Doctor's Name\n";
	$error_practice = "Practice Name\n";*/
	//if (empty($phone)) {
	//echo "\nPhone\nEmail\nDoctor's Name\nPractice Name";
	/*} elseif (empty($email)) {
	echo "\nEmail";
	} elseif (empty($doctors_name)) {
	echo "\nDoctor's Name";
	} elseif (empty($practice_name)) {
	echo "\nPractice Name";	
	\n$error_phone\n$error_email\n$error_name\n$error_practice\n";*/
} else {
header("Location: http://www.opt-technology.com/survey-confirmation.htm");
mail("dta@comcast.net, nwilhelm@azmaneye.com, eyeazman@aol.com", "survey submission from website", $body, "From: $email" );
}
} else { 
header("Location: http://www.opt-technology.com/error.htm");
} 

";

?>
hawleyjr | 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]

Posted: Sat May 27, 2006 11:45 am
by hawleyjr
You need to close this string:

Code: Select all

$body = "
GENERAL INFORMATION


Practice Name: $practice_name\n
Doctor's Name: $doctors_name\n
Office Address: $officeaddress1\n  $officeaddress2\n
Phone: $phone\n
E-Mail: $email\n
Graduated from and year: $school\n
Website: $website\n

Posted: Sat May 27, 2006 11:50 am
by Hazarrd
i closed it with " and it still gives me an error...i tried it both ways.

Posted: Sat May 27, 2006 11:55 am
by hawleyjr
Hazarrd wrote:i closed it with " and it still gives me an error...i tried it both ways.
Remove the "; from the very bottom of you code. that doesn't belong there.

Posted: Sat May 27, 2006 11:57 am
by Hazarrd
still gives me an error for the same line

Posted: Sat May 27, 2006 11:59 am
by hawleyjr
Hazarrd wrote:still gives me an error for the same line
Looks good to me: :wink:

Code: Select all

<?php
if(isset($_POST['submit'])) {
$phone = $_POST['phone'];
$email = $_POST['email'];
$doctors_name = $_POST['doctors_name'];
$practice_name = $_POST['practice_name'];
$school = $_POST['school'];
//foreach($_POST['office_descr'] as $value1) {
//$office_descr_msg .= "Office description: $value1\n";
//      }

$body = "
GENERAL INFORMATION


Practice Name: $practice_name\n
Doctor's Name: $doctors_name\n
Office Address: $officeaddress1\n  $officeaddress2\n
Phone: $phone\n
E-Mail: $email\n
Graduated from and year: $school\n
Website: $website\n";

if (empty($phone) || empty($email) || empty($dcotors_name) || empty($practice_name)) {
        header("Location: http://www.opt-technology.com/incomplete_error.htm");
/*      $error_phone = "Phone\n";
        $error_email = "Email\n";
        $error_name = "Doctor's Name\n";
        $error_practice = "Practice Name\n";*/
        //if (empty($phone)) {
        //echo "\nPhone\nEmail\nDoctor's Name\nPractice Name";
        /*} elseif (empty($email)) {
        echo "\nEmail";
        } elseif (empty($doctors_name)) {
        echo "\nDoctor's Name";
        } elseif (empty($practice_name)) {
        echo "\nPractice Name"; 
        \n$error_phone\n$error_email\n$error_name\n$error_practice\n";*/
} else {
header("Location: http://www.opt-technology.com/survey-confirmation.htm");
mail("dta@comcast.net, nwilhelm@azmaneye.com, eyeazman@aol.com", "survey submission from website", $body, "From: $email" );
}
} else {
header("Location: http://www.opt-technology.com/error.htm");
}



?>

Posted: Sat May 27, 2006 12:04 pm
by Hazarrd
i get an error on this line now...

Code: Select all

header("Location: http://www.opt-technology.com/incomplete_error.htm");

Posted: Sat May 27, 2006 12:09 pm
by twigletmac
What does the error say?

Mac

Posted: Sat May 27, 2006 12:11 pm
by Hazarrd
Parse error: parse error in /htdocs/opt-technology/survey_mailer_contacts.php on line 125

type

Posted: Sat May 27, 2006 12:22 pm
by penpaper
Did you find that you have a typo in the line

Code: Select all

if (empty($phone) || empty($email) || empty($dcotors_name) || empty($practice_name)) {
doctors is spelled dcotors :?

Posted: Sat May 27, 2006 12:24 pm
by Hazarrd
ah, didnt see that, but still no dice....error still on the line after it. please keep the suggestions coming, im very frustrated.

Posted: Sat May 27, 2006 12:27 pm
by hawleyjr
Hazarrd wrote:ah, didnt see that, but still no dice....error still on the line after it. please keep the suggestions coming, im very frustrated.
Alright, I just ran the code an had no errrors???

:roll: :roll:

Posted: Sat May 27, 2006 12:56 pm
by RobertGonzalez
Hazarrd wrote:ah, didnt see that, but still no dice....error still on the line after it. please keep the suggestions coming, im very frustrated.
Post the exact error. Then look at the line the error is reported at AND the line just before it.

Posted: Sat May 27, 2006 12:57 pm
by Hazarrd
i dont really care about the field checking at the end. if i just wanted to have it send to the emails at the end and direct the user to that site after submission, how would i code it?

Posted: Sat May 27, 2006 1:00 pm
by RobertGonzalez
Did you notice that you were header redirecting before the mail was sent? I just noticed that.

What I would do is visit the PHP manual for mail(), copy their example and run it. Then tewak it your needs until it works the way you want.