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
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 11:11 am
hawleyjr | Please use 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
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]
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat May 27, 2006 11:45 am
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
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 11:50 am
i closed it with " and it still gives me an error...i tried it both ways.
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat May 27, 2006 11:55 am
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.
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 11:57 am
still gives me an error for the same line
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat May 27, 2006 11:59 am
Hazarrd wrote: still gives me an error for the same line
Looks good to me:
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");
}
?>
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 12:04 pm
i get an error on this line now...
Code: Select all
header("Location: http://www.opt-technology.com/incomplete_error.htm");
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Sat May 27, 2006 12:09 pm
What does the error say?
Mac
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 12:11 pm
Parse error: parse error in /htdocs/opt-technology/survey_mailer_contacts.php on line 125
penpaper
Forum Newbie
Posts: 15 Joined: Tue May 23, 2006 6:45 pm
Location: Coudersport, PA, USA
Post
by penpaper » Sat May 27, 2006 12:22 pm
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
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 12:24 pm
ah, didnt see that, but still no dice....error still on the line after it. please keep the suggestions coming, im very frustrated.
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat May 27, 2006 12:27 pm
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???
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Sat May 27, 2006 12:56 pm
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.
Hazarrd
Forum Newbie
Posts: 8 Joined: Sat May 27, 2006 11:09 am
Post
by Hazarrd » Sat May 27, 2006 12:57 pm
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?
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Sat May 27, 2006 1:00 pm
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.