Jump to content


Photo

need help with mailer code


  • Please log in to reply
2 replies to this topic

#1 Codeman0013

Codeman0013
  • Members
  • PipPip
  • Member
  • 20 posts
  • LocationCentral Illinois USA

Posted 16 August 2006 - 03:11 PM

Hello I'm a newbie to php so im wondering if someone could help me debug some code problems i'm having. On one of my pages i have a set of like 6 check boxes and the user can select 1-6 of them on the next page it verify's their selections (which works). If all of this goes well it is supposed to email it on the next page problem is the email does not get the data and its not even sending that field. At one point i had the field sending the message of Occupation:Array instead of saying what was in the array any help would be greatly appreciated. Here is both pages the verify and the mailer..


<table> <?php foreach($_POST as $key) { $_POST[$key] = stripslashes(trim(str_replace("'","",$_POST[$key]))); } print '<tr><td>Date: </td><td> '.$_POST['fielddate'].'</td></tr>'; print '<tr><td>Name: </td><td> '.$_POST['fieldname'].'</td></tr>'; print '<tr><td>Farm Name: </td><td> '.$_POST['fieldfarmname'].'</td></tr>'; print '<tr><td>Spouse Name: </td><td> '.$_POST['fieldspousename'].'</td></tr>'; print '<tr><td>Address: </td><td> '.$_POST['fieldaddress'].'</td></tr>'; print '<tr><td>City: </td><td> '.$_POST['fieldcity'].'</td></tr>'; print '<tr><td>State: </td><td> '.$_POST['fieldstate'].'</td></tr>'; print '<tr><td>Zip Code: </td><td> '.$_POST['fieldzip'].'</td></tr>'; print '<tr><td>County: </td><td> '.$_POST['fieldcounty'].'</td></tr>'; print '<tr><td>Phone: </td><td> '.$_POST['fieldphone'].'</td></tr>'; print '<tr><td>E-mail: </td><td> '.$_POST['fieldemail'].'</td></tr>'; print '<tr><td>Age: </td><td> '.$_POST['Age'].'</td></tr>'; print "<tr><td>Occupation: </td><td> "; for ($i=0;$i<count($_POST['fieldoccupation']);$i++) { print $_POST['fieldoccupation'][$i] . "<br>\n"; } print "</td></tr>"; print '<tr><td>Do you want to receive the Illinois Soybean Review?: </td><td> '.$_POST['Review'].'</td></tr>'; print '<tr><td>Acres Farmed: </td><td> '.$_POST['fieldacres'].'</td></tr>'; print '<tr><td>Soybean Acres: </td><td> '.$_POST['fieldsoybeanacres'].'</td></tr>'; print '<tr><td>Type of Membership: </td><td> '.$_POST['Membership'].'</td></tr>'; for ($i=0;$i<count($_POST['fieldoccupation']);$i++) { print "<input type=\"hidden\" name=\"fieldoccupation[]\" value=\"".$_POST['fieldoccupation'][$i] . "\"/>\n"; } foreach($_POST as $key) { print "<input type=\"hidden\" name=\"$key\" value=\"$_POST[$key]\" />"; } ?> </table> <form action="/membership/application/mailapp.php" method="post"> <input type="hidden" name="fielddate" value="<?php echo $_POST['fielddate']?>"> <input type="hidden" name="fieldname" value="<?php echo $_POST['fieldname']?>"> <input type="hidden" name="fieldfarmname" value="<?php echo $_POST['fieldfarmname']?>"> <input type="hidden" name="fieldspousename" value="<?php echo $_POST['fieldspousename']?>"> <input type="hidden" name="fieldaddress" value="<?php echo $_POST['fieldaddress']?>"> <input type="hidden" name="fieldcity" value="<?php echo $_POST['fieldcity']?>"> <input type="hidden" name="fieldstate" value="<?php echo $_POST['fieldstate']?>"> <input type="hidden" name="fieldzip" value="<?php echo $_POST['fieldzip']?>"> <input type="hidden" name="fieldcounty" value="<?php echo $_POST['fieldcounty']?>"> <input type="hidden" name="fieldphone" value="<?php echo $_POST['fieldphone']?>"> <input type="hidden" name="fieldemail" value="<?php echo $_POST['fieldemail']?>"> <input type="hidden" name="Age" value="<?php echo $_POST['Age']?>"> <input type="hidden" name"fieldoccupation[]" value="<?php echo $_POST['fieldoccupation[]']?>" > <input type="hidden" name="Review" value="<?php echo $_POST['Review']?>"> <input type="hidden" name="fieldacres" value="<?php echo $_POST['fieldacres']?>"> <input type="hidden" name="fieldsoybeanacres" value="<?php echo $_POST['fieldsoybeanacres']?>"> <input type="hidden" name="Membership" value="<?php echo $_POST['Membership']?>"> <input type="submit" name="submit" value="Send Email"> <input type="button" value="Edit Info" onclick="history.back(-1)"> </form>



mailer page:

<?php // Set things up here $date = $_POST['fielddate']; $name = $_POST['fieldname']; $farmname = $_POST['fieldfarmname']; $spousename = $_POST['fieldspousename']; $address = $_POST['fieldaddress']; $city = $_POST['fieldcity']; $state = $_POST['fieldstate']; $zip = $_POST['fieldzip']; $county = $_POST['fieldcounty']; $phone = $_POST['fieldphone']; $email = $_POST['fieldemail']; $age = $_POST['Age']; $occupation = explode ("|", $_POST['fieldoccupation']); $review = $_POST['Review']; $acres = $_POST['fieldacres']; $soybeans = $_POST['fieldsoybeanacres']; $membership = $_POST['Membership']; $to = 'isintern@jonesthomas.com'; $headers = 'From: ilsoy'. $subject = 'Illinois Soybean Association Membership Application'; // Start the message $message = "Hello the following person has requested to join the Illinois Soybean Association\n Date: $date\n Name: $name\n Farm Name: $farmname\n Spouse Name: $spousename\n Address: $address\n City: $city\n State: $state\n Zip: $zip\n County: $county\n Phone: $phone\n Email: $email\n Age: $age\n Occupation: $occupation\n Do you want to receive the Illinois Soybean Review?: $review\n Acres farmed: $acres\n Soybean acres: $soybeans\n Please choose your membership: $membership\n"; print_r($_POST); exit(); // Finally send it off. //if(mail($to, $subject, $message, $headers)) //{ // header("Location: /membership/application/thankyou.php"); //} //else //{ // header("Location: /membership/application/"); //} ?>


Remember to always look for those dang ; they can be a killer!

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 16 August 2006 - 03:36 PM

I doubt anyone is going to feel inclined to wade through all that. How about putting each PHP statement on a separate line for starters?
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 karthikeyan_coder

karthikeyan_coder
  • Members
  • PipPipPip
  • Advanced Member
  • 201 posts

Posted 16 August 2006 - 06:18 PM

yes, its hard to read code by scrolling. so give us a readable code.
www.karthi.us




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users