Need help debugging a Form script.

I have been racking my brain for three weeks now, trying to figure out why this script is not working. Take a look, I will be sure to make a donation if we get this one: Thank you in advance for any insight you may have.

[php]

<?php include "info.php"; $redirect = "http://www.nutritionalcourses.com/thankyou3.htm"; // send thankyou email to user $mailto = $contact['email']; $subject = "Thank you from The Nutritional Seminars"; $mailfrom = $rep_emails[$contact['state_rep']]; include 'emailbody3.php'; $body = "Dear ".$contact['name'].",nn".$emailbody3; $mail1sent = mail($mailto, $subject, $body, "From: $mailfrom"); // send a summary email to sales reps address $mailto = $rep_emails[$contact['state_rep']]; $subject = "Standard Process Seminar Signup"; $mailfrom = $contact['email']; // prepare email body text $body = "Practice Name: ".$contact['practice_name']."n"; $body = "Name: ".$contact['name']."n"; $body .= "Address: n".$contact['address']."n"; if($contact['address2'] != "") $body .= $contact['address2']."n"; $body .= $contact['city']." ".$contact['state']." ".$contact['zip']."nn"; $body .= "Email: ".$contact['email']."nn"; $body .= "Phone Number: ".$contact['phone_number']."nn"; $body .= "Fax: ".$contact['fax']."nn"; $body .= "What Seminar Are You Intrested In: ".$contact['seminar']."nn"; $body .= "What State is this Seminar in: ".$contact['state_rep']."nn"; $body .= "What is the Month of the Seminar: ".$contact['seminar_month']."nn"; $body .= "How would you like to pay: ".$contact['pay_method']."nn"; $body .= "How Did You Hear About Us: ".$contact['how_did_you_hear_about_us']."nn"; $body .= "comment: ".$contact['comment']."nn"; $body .= "Time Received: ".date("F j, Y, g:i a", time())."nnn"; $mail2sent = mail($mailto, $subject, $body, "From: $mailfrom"); // make sure the email was sent if ($mail1sent && $mail2sent) { header("Location: $redirect"); } else { // This echo's the error message if the email did not send. // You could change the text in between the

tags. echo('

Mail was not sent please fill out the proper email address and click on one of our packages to send correctly. Please Print and fax form to correct sales representative if more problems occur. Sorry for any inconvenience this may have caused you.

'); } ?>

[/php]
**MOD EDIT - Added PHP BBCode for better readability.

Try changing

include 'emailbody3.php';

$body = “Dear “.$contact[‘name’].”,nn”.$emailbody3;

to

[php]
$emailbody = include(“http://www.yourdomain.com/emailbody3.php”);
$body = “”$emailbody"n";[/php]

what is not working?
any errors?

As Q1712 said: What is or isn’t working? What Errors are you getting?

If you are getting a blank page when this script is ran you should try turning on errors. To do this you simply need to place the following at the top of your page.

error_reporting(E_ALL);

This will force the parser to display any and all errors. Sometimes these are turned off for security reasons by the server administrator in the php.ini file.

Hope this helps.

First of all,

I appreciate everyone’s help. Here is the error after I switched line 15 and 16.

Warning: main(): URL file-access is disabled in the server configuration in /home/content/w/i/z/wizzy5/html/formmail3.php on line 15

Warning: main(http://www.thenutritionalseminars.com/emailbody3.php): failed to open stream: no suitable wrapper could be found in /home/content/w/i/z/wizzy5/html/formmail3.php on line 15

Warning: main(): URL file-access is disabled in the server configuration in /home/content/w/i/z/wizzy5/html/formmail3.php on line 15

Warning: main(http://www.thenutritionalseminars.com/emailbody3.php): failed to open stream: no suitable wrapper could be found in /home/content/w/i/z/wizzy5/html/formmail3.php on line 15

Warning: main(): Failed opening ‘http://www.thenutritionalseminars.com/emailbody3.php’ for inclusion (include_path=’.:/usr/local/lib/php’) in /home/content/w/i/z/wizzy5/html/formmail3.php on line 15
No recipient addresses found in header No recipient addresses found in header
Warning: Cannot modify header information - headers already sent by (output started at /home/content/w/i/z/wizzy5/html/formmail3.php:15) in /home/content/w/i/z/wizzy5/html/formmail3.php on line 69

I switched line 15 to:

$emailbody = include “emailbody3.php”;

$body = “”$emailbody"n";

and got the same error I received earlier:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

After I added the error_reporting(E_ALL); I recieved the following error:

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 14
No recipient addresses found in header
Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 25

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/formmail3.php on line 25

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 29

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 33

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 35

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 37

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 39

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 43

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 43

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 44

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 46

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 48

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 50

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 52

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 54

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 56

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 58

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 60

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 62
No recipient addresses found in header
Warning: Cannot modify header information - headers already sent by (output started at /home/content/w/i/z/wizzy5/html/formmail3.php:11) in /home/content/w/i/z/wizzy5/html/formmail3.php on line 72

I figure you probably want the html I am referring to so here it is:

[code]

Contact Us and Sign Up For a Seminar body { background-color: #FFFFFF; } div.c2 {width:616px;height:620px;overflow:scroll;font-size: 14px;} span.c1 {font-family: arial, helvetica; font-size: 80%}
log in about us
about the speakers listing by date listing by speaker listing by state recordings
XXXXXXXX

When filling out this form be sure enable java script. Please specify State and Seminar name so that we can properly sign you up for the correct seminar. Thanks! We do not accept payment online due to the large number of representatives hosting events. Please indicate how you would like to pay and we will contact you asap.

Seminar Sign-up Form

Practice Name:

Health Care Professional Name:


Address:

Address2:

City:



State/Province:

Please select... AL - Alabama AK - Alaska AS - American Samoa AZ - Arizona AR - Arkansas AE - Armed Forces AA - Armed Forces Americas AP - Armed Forces Pacific CA - California CO - Colorado CT - Connecticut DE - Delaware DC - District of Columbia FM - Federated States of Micronesia FL - Florida GA - Georgia GU - Guam HI - Hawaii ID - Idaho IL - Illinois IN - Indiana IA - Iowa KS - Kansas KY - Kentucky LA - Louisiana ME - Maine MH - Marshall Islands MD - Maryland MA - Massachusetts MI - Michigan MN - Minnesota MS - Mississippi MO - Missouri MT - Montana NE - Nebraska NV - Nevada NH - New Hampshire NJ - New Jersey NM - New Mexico NY - New York NC - North Carolina ND - North Dakota MP - Northern Mariana Islands OH - Ohio OK - Oklahoma OR - Oregon PW - Palau PA - Pennsylvania PR - Puerto Rico RI - Rhode Island SC - South Carolina SD - South Dakota TN - Tennessee TX - Texas UT - Utah VT - Vermont VI - Virgin Islands VA - Virginia WA - Washington WV - West Virginia WI - Wisconsin WY - Wyoming AB - Alberta BC - British Columbia MB - Manitoba NB - New Brunswick NF - Newfoundland NT - North West Territories NS - Nova Scotia ON - Ontario PE - Prince Edward Island QC - Quebec SK - Saskatchewan YT - Yukon ACT - Australian Capital Territory NSW - New South Wales NT - Northern Territory QLD - Queensland SA - South Australia TAS - Tasmania VIC - Victoria WA - Western Australia N/A - Not Applicable
Zip:

Phone Number:

Fax:



Email Address:

What Seminar would you like to sign up for?:
Please select... Dr. Michael Dobbins Dr. Janet Lang Dr. Jay Robbins Dr. Bruce Bond Angela Hywood ND Dr. James Powell Kerry Bone Dr. Lynne August MD Dr. Jay Sandweiss Dr. Darren Schmidt Dr. Stuart White

What State is this Seminar in?:
Please select... Iowa Illinois Southern Illinois Indiana Kansas Southeast Michigan Greater Michigan Western Missouri Minnesota Ohio Wisconsin

What is the Month of the Seminar?
Please select... January February March April May June July August September October November December

How Would You like to Pay when We Call You?
Please select... Check Credit Card Cash

How did you hear About Us?:
Please select... From another seminar I attended From a friend Seminar Brochure Yahoo Google Other

If other, please specify below:

Do you have any Questions or Comments?

 

 
[/code]

Try this at the begining
[php]
$mime_boundary = “----Your_Company_Name----”.md5(time());
$body .= “–$mime_boundaryn”;
$body .= “Content-Type: text/plain; charset=UTF-8n”;
$body .= “Content-Transfer-Encoding: 8bitnn”;[/php]

I added the code:

[code]<?php
$mime_boundary = “----Nutritional_Courses----”.md5(time());

error_reporting(E_ALL);

include “info.php”;

$redirect = “thankyou3.htm”;

// send thankyou email to user

$mailto = $contact[‘email’];

$subject = “Thank you from The Nutritional Seminars”;

$mailfrom = $rep_emails[$contact[‘state_rep’]];

$emailbody = include “emailbody3.php”;

$body = “”$emailbody"n";

$mail1sent = mail($mailto, $subject, $body, “From: $mailfrom”);

// send a summary email to sales reps address

$mailto = $rep_emails[$contact[‘state_rep’]];

$subject = “Standard Process Seminar Signup”;

$mailfrom = $contact[‘email’];

// prepare email body text

$body .= “–$mime_boundaryn”;
$body .= “Content-Type: text/plain; charset=UTF-8n”;
$body .= “Content-Transfer-Encoding: 8bitnn”;

$body = "Practice Name: ".$contact[‘practice_name’].“n”;

$body = "Name: ".$contact[‘name’].“n”;

$body .= “Address: n”.$contact[‘address’].“n”;

if($contact[‘address2’] != “”)

$body .= $contact[‘address2’].“n”;

$body .= $contact[‘city’]." “.$contact[‘state’].”
".$contact[‘zip’].“nn”;

$body .= "Email: ".$contact[‘email’].“nn”;

$body .= "Phone Number: ".$contact[‘phone_number’].“nn”;

$body .= "Fax: ".$contact[‘fax’].“nn”;

$body .= "What Seminar Are You Intrested In: ".$contact[‘seminar’].“nn”;

$body .= "What State is this Seminar in: ".$contact[‘state_rep’].“nn”;

$body .= "What is the Month of the Seminar: ".$contact[‘seminar_month’].“nn”;

$body .= "How would you like to pay: ".$contact[‘pay_method’].“nn”;

$body .= "How Did You Hear About Us: ".$contact[‘how_did_you_hear_about_us’].“nn”;

$body .= "comment: ".$contact[‘comment’].“nn”;

$body .= "Time Received: ".date(“F j, Y, g:i a”, time()).“nnn”;

$mail2sent = mail($mailto, $subject, $body, “From: $mailfrom”);

// make sure the email was sent

if ($mail1sent && $mail2sent) {

header(“Location: $redirect”);

} else {

// This echo’s the error message if the email did not send.

// You could change the text in between the

tags.

echo(‘

Mail was not sent please fill out the proper email address
and click on one of our packages to send correctly. Please Print and fax
form to correct sales representative if more problems occur. Sorry for any inconvience
this may have caused you.

’);

}

?>[/code]

and got another error…

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 12

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 16

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/formmail3.php on line 16

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 3

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 3

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 11

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 11

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 12

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 12

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 13

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 13

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 14

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 14
No recipient addresses found in header
Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 26

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/formmail3.php on line 26

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 30

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 38

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 40

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 42

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 44

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 48

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 48

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 49

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 51

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 53

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 55

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 57

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 59

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 61

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 63

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 65

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/formmail3.php on line 67
No recipient addresses found in header
Warning: Cannot modify header information - headers already sent by (output started at /home/content/w/i/z/wizzy5/html/formmail3.php:12) in /home/content/w/i/z/wizzy5/html/formmail3.php on line 77

please swich the lines …
[php]include ‘emailbody3.php’;
$body = “Dear “.$contact[‘name’].”,nn”.$emailbody3;[/php]
back to what they where. they have been allright.

where should $contact come from and what should be in there.
as u use is after including info.php it should be defined in there, is it?

ok. got it:
please use $_POST[‘contact’][‘xyz’] instead of $contact[‘xyz’].

Now I am getting:

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 3

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 3

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 11

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 11

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 12

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 12

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 13

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 13

Notice: Undefined variable: contact in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 14

Notice: Undefined index: in /home/content/w/i/z/wizzy5/html/emailbody3.php on line 14

Notice: Undefined variable: emailbody3 in /home/content/w/i/z/wizzy5/html/formmail3.php on line 20

Warning: Cannot modify header information - headers already sent by (output started at /home/content/w/i/z/wizzy5/html/emailbody3.php:3) in /home/content/w/i/z/wizzy5/html/formmail3.php on line 77

The code is now:

[php]

<?php $mime_boundary = "----Nutritional_Courses----".md5(time()); error_reporting(E_ALL); include "info.php"; $redirect = "thankyou3.htm"; // send thankyou email to user $mailto = $_POST['contact']['email']; $subject = "Thank you from The Nutritional Seminars"; $mailfrom = $rep_emails[$_POST['contact']['state_rep']]; include 'emailbody3.php'; $body = "Dear ".$_POST['contact']['name'].",nn".$emailbody3; $mail1sent = mail($mailto, $subject, $body, "From: $mailfrom"); // send a summary email to sales reps address $mailto = $rep_emails[$_POST['contact']['state_rep']]; $subject = "Standard Process Seminar Signup"; $mailfrom = $_POST['contact']['email']; // prepare email body text $body .= "--$mime_boundaryn"; $body .= "Content-Type: text/plain; charset=UTF-8n"; $body .= "Content-Transfer-Encoding: 8bitnn"; $body = "Practice Name: ".$_POST['contact']['practice_name']."n"; $body = "Name: ".$_POST['contact']['name']."n"; $body .= "Address: n".$_POST['contact']['address']."n"; if($_POST['contact']['address2'] != "") $body .= $_POST['contact']['address2']."n"; $body .= $_POST['contact']['city']." ".$_POST['contact']['state']." ".$_POST['contact']['zip']."nn"; $body .= "Email: ".$_POST['contact']['email']."nn"; $body .= "Phone Number: ".$_POST['contact']['phone_number']."nn"; $body .= "Fax: ".$_POST['contact']['fax']."nn"; $body .= "What Seminar Are You Intrested In: ".$_POST['contact']['seminar']."nn"; $body .= "What State is this Seminar in: ".$_POST['contact']['state_rep']."nn"; $body .= "What is the Month of the Seminar: ".$_POST['contact']['seminar_month']."nn"; $body .= "How would you like to pay: ".$_POST['contact']['pay_method']."nn"; $body .= "How Did You Hear About Us: ".$_POST['contact']['how_did_you_hear_about_us']."nn"; $body .= "comment: ".$_POST['contact']['comment']."nn"; $body .= "Time Received: ".date("F j, Y, g:i a", time())."nnn"; $mail2sent = mail($mailto, $subject, $body, "From: $mailfrom"); // make sure the email was sent if ($mail1sent && $mail2sent) { header("Location: $redirect"); } else { // This echo's the error message if the email did not send. // You could change the text in between the

tags. echo('

Mail was not sent please fill out the proper email address and click on one of our packages to send correctly. Please Print and fax form to correct sales representative if more problems occur. Sorry for any inconvience this may have caused you.

'); } ?>

[/php]

on a positive note, I have recieved a feedback thankyou note.

It says,

Subject: Thanks you from The Nutritional Seminars

Body: Dear Peter Wisniewski,

this shows u the exact line numbers whereu have forgoten to replace it.

take a look at the file emailbody3.php.

Here’s the problem:
You’re using the following format for your form element names:

contact['email']

Now you try to retrieve its value in PHP like so:

[php]
$contact[‘email’]
[/php]

This would have worked should register_globals be enabled. There’s a GOOD reason however that this is disabled. Read up on PHP security to learn why.

The examples given show the retrieving of this value like so:

[php]
$_POST[‘contact’][‘email’]
[/php]

Which is, as far as I know, not correct syntax to retrieve the value.
I’d suggest you try to retrieve the array first, and then try to discern its values:

[php]
$contact = $_POST[‘contact’];
$contactEmail = $contact[‘email’];
[/php]

This may not work as I’ve never worked with arrays as form element names, but it should.

On a sidenote: never trust user input. Always check the submitted values to see if there’s anything in there that might break your code or have otherwise unpleasant (side-)effects.

Form is fixed!!!

I want to thank everyone who helped me solve this difficult problem.

The globals where turned off, so I used:

$_post[‘email’]

I also took the contacts and the brackets off the names in contactus.html

It also liked the $mime_Boundary stuff

I also read a bit on globals and security which helped explain other problems I have been having.

I will donate, it is nice to know that people in the php world are genuinely nice and willing to help beginners.

Have a great weekend!

-pete

there realy is: a lot of people (includin myselfe) don’t care about defining variables in php, and if u have a variable $loggedin that has never been defined anyone could call ur script like urscript.php?loggedin=1, and tey are logged in without providing the password. big securety risk.

u still don’t trust me?
it is correct syntax. or what syntax u would use to acces a key of the posted array ‘contact’ ?

this work. don’t put ur light under a stool.

the best thing that ever been said in this forum: the user is ur enemy. 99,99% are not but if u realy get contact to one of this 0,01% (every 10.000ndth person) u’ll get into big trouble. so hope for the best, but expect the worth.

Like I said, I never use arrays as form element names, so I’ve never run into the problem. Using $var[index1][index2] implies a multidimensional array. Is POST data to be considered as such? It may or may not work, but in case of doubt, work around it.

Yes, i’ll take a look at the file emailbody3.php.

Sponsor our Newsletter | Privacy Policy | Terms of Service