php error message

  • cleartango
  • Newbie
  • Newbie
  • cleartango
  • Posts: 7

Post 3+ Months Ago

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.

Notice: Undefined variable: payment in /home/barfutu1/public_html/anothertry4.php on line 71

Notice: Undefined variable: payment in /home/barfutu1/public_html/anothertry4.php on line 73

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:

PHP Code: [ Select ]
<?php
ini_set("display_errors", "1");
error_reporting(E_ALL);
 
$to = "emailaddress";
$to2 = "emailaddress";
$to3 = "emailaddress";
 
$from = $_REQUEST['contactemail'] ;
$name = $_REQUEST['contactname'] ;
$headers = "From: $from";
$subject = "Request for Conference Places in York on Dec 10";
 
$fields = array();
$fields{'contactname'} = " Contact Name";
$fields{'contactemail'} = "  Contact Email";
$fields{'contactphone'} = "  Contact Phone";
$fields{'contactaddress'} = "   Contact Address";
$fields{'organisation'} = " Organisation";
$fields{'delegate1name'} = "Del 1 NAME";
$fields{'delegate1job'} = "Del 1 JOB";
$fields{'delegate1email'} = " Del 1 EMAIL";
$fields{'delegate2name'} = "Del 2 NAME";
$fields{'delegate2job'} = "Del 2 JOB";
$fields{'delegate2email'} = " Del 2 EMAIL";
$fields{'delegate3name'} = "Del 3 NAME";
$fields{'delegate3job'} = "Del 3 JOB";
$fields{'delegate3email'} = " Del 3 EMAIL";
$fields{'delegate4name'} = "Del 4 NAME";
$fields{'delegate4job'} = "Del 4 JOB";
$fields{'delegate4email'} = " Del 4 EMAIL";
$fields{'delegate5name'} = "Del 5 NAME";
$fields{'delegate5job'} = "Del 5 JOB";
$fields{'delegate5email'} = " Del 5 EMAIL";
$fields{'delegate6name'} = "Del 6 NAME";
$fields{'delegate6job'} = "Del 6 JOB";
$fields{'delegate6email'} = " Del 6 EMAIL";
$fields{'delegate7name'} = "Del 7 NAME";
$fields{'delegate7job'} = "Del 7 JOB";
$fields{'delegate7email'} = " Del 7 EMAIL";
$fields{'delegate8name'} = "Del 8 NAME";
$fields{'delegate8job'} = "Del 8 JOB";
$fields{'delegate8email'} = " Del 8 EMAIL";
$fields{'delegate9name'} = "Del 9 NAME";
$fields{'delegate9job'} = "Del 9 JOB";
$fields{'delegate9email'} = " Del 9 EMAIL";
$fields{'delegate10name'} = "Del 10 NAME";
$fields{'delegate10job'} = "Del 10 JOB";
$fields{'delegate10email'} = " Del 10 EMAIL";
$fields{'payment'} = "   Payment";
$fields{'terms'} = "Terms";
 
 
$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]); }
 
$headers2 = "From: emailaddress";
$subject2 = "Managing the Evening and Night-time Economy in Yorkshire and Humber";
$autoreply = "Thank you for your reservation for the 'Managing the Evening and Night-time Economy in Yorkshire and Humber' conference.
 
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.
 
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";
 
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
$send3 = mail($to2, $subject, $body, $headers);
$send4 = mail($to3, $subject, $body, $headers);
 
if($payment=="bacs")
{header("Location: url"); exit(); }
elseif($payment=="card")
{header("Location: url"); exit(); }
else
{header("Location: url"); exit(); }
 
?>
  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
Moderator Remark: Added [php] tags around code
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6252
  • Loc: Seattle, WA

Post 3+ Months Ago

It's complaining that you're trying to use the variable $payment before it was ever assigned a value. If this is something that is supposed to come from the form, it looks like you're never setting $payment to any value in your script.
  • cleartango
  • Newbie
  • Newbie
  • cleartango
  • Posts: 7

Post 3+ Months Ago

Thanks Spork!

What about the third error message there. What does that mean? What's wrong in my code to trigger that and how can I modify it without making my code do sthg different?
  • cleartango
  • Newbie
  • Newbie
  • cleartango
  • Posts: 7

Post 3+ Months Ago

Have got rid of whitespace in the code...and now there seems to be a new issue ...

When it gets to this:

Code: [Select]
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(); }

even if payment =="bacs" or "card" it just does the action required if neither of these is true, which in this case means returning the form for user to complete anew.

Anybody have any thoughts on why this is happening or how to tackle it?

Thanks

Mick
  • cleartango
  • Newbie
  • Newbie
  • cleartango
  • Posts: 7

Post 3+ Months Ago

Thanks!!

the user enters payment type as shown in the html based on one of two checkbox.

Code: [ Select ]
<tr>
      <td colspan="3" class="labelcell" width="400"><font size="2"><label for="card">Debit/Credit card</label></font></td>
      <td> <input type="radio" name="payment" id="payment" value="card" tabindex="36"></td>
     </tr>
     <tr>
      <td colspan="3" class="labelcell"><font size="2"><label for="bacs">BACS transfer</label></font></td>
      <td><input type="radio" name="payment" id="payment" value="bacs" tabindex="37"></td>
     </tr>
  1. <tr>
  2.       <td colspan="3" class="labelcell" width="400"><font size="2"><label for="card">Debit/Credit card</label></font></td>
  3.       <td> <input type="radio" name="payment" id="payment" value="card" tabindex="36"></td>
  4.      </tr>
  5.      <tr>
  6.       <td colspan="3" class="labelcell"><font size="2"><label for="bacs">BACS transfer</label></font></td>
  7.       <td><input type="radio" name="payment" id="payment" value="bacs" tabindex="37"></td>
  8.      </tr>

it's currently returning as if no payment is submitted.
I've added in echo $payment; but it's not giving me any info, however as it's taking the action as if no payment type submitted i'm guessing it's not using that info as it should.
i added this into the code

Code: [ Select ]
ini_set("display_errors", "1");
error_reporting(E_ALL);
  1. ini_set("display_errors", "1");
  2. error_reporting(E_ALL);


this tells me
Notice: Undefined variable: payment in /home/barfutu1/public_html/anothertry4.php on line 69

Notice: Undefined variable: payment in /home/barfutu1/public_html/anothertry4.php on line 70

Notice: Undefined variable: payment in /home/barfutu1/public_html/anothertry4.php on line 72

Warning: Cannot modify header information - headers already sent by (output started at /home/barfutu1/public_html/anothertry4.php:69) in /home/barfutu1/public_html/anothertry4.php on line 75

Am a newbie at this, so how do I define the $payment variable? what's the code for that? I would have thought that the variable would be defined when the user checks a checkbox and then used to go to the correct url. Despite what the code says all the urls are different.

Thanks guys!!!

Mick
  • cleartango
  • Newbie
  • Newbie
  • cleartango
  • Posts: 7

Post 3+ Months Ago

Thanks guys!

I added

$payment=$_POST['payment'];

..and this has done the trick.

Couldn't be happier!!

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 142 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.