PHP form processing - getting odd error message & need fix
Posted: Mon Nov 23, 2009 9:02 pm
Hi
I have a php form processing script set up.
When my form is submitted, my users should be transferred to a webpage depending on what answer they give to a question, however they are currently seeing the following error message.
Warning: Cannot modify header information - headers already sent by (output started at /home/barf1/public_html/anothertry4.php:3) in /home/barfutu1/public_html/anothertry4.php on line 76
Any ideas what I need to do to rectify this situation? Does my code need tweaking? And if so how? php code is enclosed below:
1. <?php
2. ini_set("display_errors", "1");
3. error_reporting(E_ALL);
4.
5. $to = "emailaddress";
6. $to2 = "emailaddress";
7. $to3 = "emailaddress";
8.
9. $from = $_REQUEST['contactemail'] ;
10. $name = $_REQUEST['contactname'] ;
11. $headers = "From: $from";
12. $subject = "Request for Conference Places in York on Dec 10";
13.
14. $fields = array();
15. $fields{'contactname'} = " Contact Name";
16. $fields{'contactemail'} = " Contact Email";
17. $fields{'contactphone'} = " Contact Phone";
18. $fields{'contactaddress'} = " Contact Address";
19. $fields{'organisation'} = " Organisation";
20. $fields{'delegate1name'} = "Del 1 NAME";
21. $fields{'delegate1job'} = "Del 1 JOB";
22. $fields{'delegate1email'} = " Del 1 EMAIL";
23. $fields{'delegate2name'} = "Del 2 NAME";
24. $fields{'delegate2job'} = "Del 2 JOB";
25. $fields{'delegate2email'} = " Del 2 EMAIL";
26. $fields{'delegate3name'} = "Del 3 NAME";
27. $fields{'delegate3job'} = "Del 3 JOB";
28. $fields{'delegate3email'} = " Del 3 EMAIL";
29. $fields{'delegate4name'} = "Del 4 NAME";
30. $fields{'delegate4job'} = "Del 4 JOB";
31. $fields{'delegate4email'} = " Del 4 EMAIL";
32. $fields{'delegate5name'} = "Del 5 NAME";
33. $fields{'delegate5job'} = "Del 5 JOB";
34. $fields{'delegate5email'} = " Del 5 EMAIL";
35. $fields{'delegate6name'} = "Del 6 NAME";
36. $fields{'delegate6job'} = "Del 6 JOB";
37. $fields{'delegate6email'} = " Del 6 EMAIL";
38. $fields{'delegate7name'} = "Del 7 NAME";
39. $fields{'delegate7job'} = "Del 7 JOB";
40. $fields{'delegate7email'} = " Del 7 EMAIL";
41. $fields{'delegate8name'} = "Del 8 NAME";
42. $fields{'delegate8job'} = "Del 8 JOB";
43. $fields{'delegate8email'} = " Del 8 EMAIL";
44. $fields{'delegate9name'} = "Del 9 NAME";
45. $fields{'delegate9job'} = "Del 9 JOB";
46. $fields{'delegate9email'} = " Del 9 EMAIL";
47. $fields{'delegate10name'} = "Del 10 NAME";
48. $fields{'delegate10job'} = "Del 10 JOB";
49. $fields{'delegate10email'} = " Del 10 EMAIL";
50. $fields{'payment'} = " Payment";
51. $fields{'terms'} = "Terms";
52.
53.
54. $body = "Request for Conference Places in York on Dec 10:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
55.
56. $headers2 = "From: emailaddress";
57. $subject2 = "Managing the Evening and Night-time Economy in Yorkshire and Humber";
58. $autoreply = "Thank you for your reservation for the 'Managing the Evening and Night-time Economy in Yorkshire and Humber' conference.
59.
60. Your conference places will be confirmed once we have received your payment. Conference details and a conference preference questionnaire will be sent to you shortly.
61.
62. If you have chosen to pay by BACS and you do NOT receive a proforma within 24 hours or if you have any questions, please contact us on emailaddress";
63.
64. $send = mail($to, $subject, $body, $headers);
65. $send2 = mail($from, $subject2, $autoreply, $headers2);
66. $send3 = mail($to2, $subject, $body, $headers);
67. $send4 = mail($to3, $subject, $body, $headers);
68.
69. if($payment=="bacs")
70. {header("Location: url"); exit(); }
71. elseif($payment=="card")
72. {header("Location: url"); exit(); }
73. else
74. {header("Location: url"); exit(); }
75.
76. ?>
Would be grateful for any help
Mick
I have a php form processing script set up.
When my form is submitted, my users should be transferred to a webpage depending on what answer they give to a question, however they are currently seeing the following error message.
Warning: Cannot modify header information - headers already sent by (output started at /home/barf1/public_html/anothertry4.php:3) in /home/barfutu1/public_html/anothertry4.php on line 76
Any ideas what I need to do to rectify this situation? Does my code need tweaking? And if so how? php code is enclosed below:
1. <?php
2. ini_set("display_errors", "1");
3. error_reporting(E_ALL);
4.
5. $to = "emailaddress";
6. $to2 = "emailaddress";
7. $to3 = "emailaddress";
8.
9. $from = $_REQUEST['contactemail'] ;
10. $name = $_REQUEST['contactname'] ;
11. $headers = "From: $from";
12. $subject = "Request for Conference Places in York on Dec 10";
13.
14. $fields = array();
15. $fields{'contactname'} = " Contact Name";
16. $fields{'contactemail'} = " Contact Email";
17. $fields{'contactphone'} = " Contact Phone";
18. $fields{'contactaddress'} = " Contact Address";
19. $fields{'organisation'} = " Organisation";
20. $fields{'delegate1name'} = "Del 1 NAME";
21. $fields{'delegate1job'} = "Del 1 JOB";
22. $fields{'delegate1email'} = " Del 1 EMAIL";
23. $fields{'delegate2name'} = "Del 2 NAME";
24. $fields{'delegate2job'} = "Del 2 JOB";
25. $fields{'delegate2email'} = " Del 2 EMAIL";
26. $fields{'delegate3name'} = "Del 3 NAME";
27. $fields{'delegate3job'} = "Del 3 JOB";
28. $fields{'delegate3email'} = " Del 3 EMAIL";
29. $fields{'delegate4name'} = "Del 4 NAME";
30. $fields{'delegate4job'} = "Del 4 JOB";
31. $fields{'delegate4email'} = " Del 4 EMAIL";
32. $fields{'delegate5name'} = "Del 5 NAME";
33. $fields{'delegate5job'} = "Del 5 JOB";
34. $fields{'delegate5email'} = " Del 5 EMAIL";
35. $fields{'delegate6name'} = "Del 6 NAME";
36. $fields{'delegate6job'} = "Del 6 JOB";
37. $fields{'delegate6email'} = " Del 6 EMAIL";
38. $fields{'delegate7name'} = "Del 7 NAME";
39. $fields{'delegate7job'} = "Del 7 JOB";
40. $fields{'delegate7email'} = " Del 7 EMAIL";
41. $fields{'delegate8name'} = "Del 8 NAME";
42. $fields{'delegate8job'} = "Del 8 JOB";
43. $fields{'delegate8email'} = " Del 8 EMAIL";
44. $fields{'delegate9name'} = "Del 9 NAME";
45. $fields{'delegate9job'} = "Del 9 JOB";
46. $fields{'delegate9email'} = " Del 9 EMAIL";
47. $fields{'delegate10name'} = "Del 10 NAME";
48. $fields{'delegate10job'} = "Del 10 JOB";
49. $fields{'delegate10email'} = " Del 10 EMAIL";
50. $fields{'payment'} = " Payment";
51. $fields{'terms'} = "Terms";
52.
53.
54. $body = "Request for Conference Places in York on Dec 10:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
55.
56. $headers2 = "From: emailaddress";
57. $subject2 = "Managing the Evening and Night-time Economy in Yorkshire and Humber";
58. $autoreply = "Thank you for your reservation for the 'Managing the Evening and Night-time Economy in Yorkshire and Humber' conference.
59.
60. Your conference places will be confirmed once we have received your payment. Conference details and a conference preference questionnaire will be sent to you shortly.
61.
62. If you have chosen to pay by BACS and you do NOT receive a proforma within 24 hours or if you have any questions, please contact us on emailaddress";
63.
64. $send = mail($to, $subject, $body, $headers);
65. $send2 = mail($from, $subject2, $autoreply, $headers2);
66. $send3 = mail($to2, $subject, $body, $headers);
67. $send4 = mail($to3, $subject, $body, $headers);
68.
69. if($payment=="bacs")
70. {header("Location: url"); exit(); }
71. elseif($payment=="card")
72. {header("Location: url"); exit(); }
73. else
74. {header("Location: url"); exit(); }
75.
76. ?>
Would be grateful for any help
Mick