Codeman0013 Posted August 16, 2006 Share Posted August 16, 2006 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..[code=php:0]<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>[/code]mailer page:[code=php:0] <?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/"); //} ?>[/code] Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 16, 2006 Share Posted August 16, 2006 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? Quote Link to comment Share on other sites More sharing options...
karthikeyan_coder Posted August 16, 2006 Share Posted August 16, 2006 yes, its hard to read code by scrolling. so give us a readable code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.