-
print_r() displays the contents of a variable. We need to find out what $_POST contains: that is all the information sent through the "post" method-- in other words, all of the information from your form.
Look through the output (best to view it in view>source) and find the value corresponding to the field in your form.
To be entirely clear-- ALL you are doing is displaying what was sent so you know how to work with it.
You can insert this code before EVERYTHING else on the page as-is:
<?php print_r($_POST); exit(); ?>
That will print out the info then stop execution: you will only get the values of POST, then after that just remove that line from the top and use your page like normal-- but then you'll know what values are being sent.
Additionally, I recommend testing this several times to find out what the possible values are-- try clicking one radio button, clicking none, clicking the others.... etc.
Once you identify a pattern that is reliable, you can program PHP to do the same. But until you know what you're looking for, it's just a guess in PHP, and especially from us here since we can't test it.
-
No change. Where do I set the $selected_radio $POST value?
I have the post values up top for 'giss1' and 'giss2'. Would I put the 'selected_radio' up there too?
-
Do you have a link you could give us? Or just post the resulting output when<?php print_r($_POST); exit(); ?> is pasted at the absolute top and a form is submitted to the page.
-
Issue Resolved!
Turns out I was all screwed up. Here's the new code:
Inserted into head:
Code:
<?PHP
$selected_radio = $_POST['session'];
print $selected_radio;
?>
form:
Code:
<form action="home_contact.php" method="post" id="frmcontactform" >
<div>
<p>*Asterisk denotes mandatory field</p>
<fieldset>
<div><label for="college">*College</label>
<input type="text" name="college" id="college" size="41" />
</div>
</fieldset>
<br />
<fieldset>
<div><label for="streetaddress">*Street Address</label>
<input type="text" name="streetaddress" id="streetaddress" size="35" />
</div>
</fieldset>
<br />
<fieldset>
<div><label for="city">*City</label>
<input type="text" name="city" id="city" size="27" />
</div>
</fieldset>
<br />
<fieldset>
<div style="padding-bottom:12px"><label for="state">*State</label>
<input type="text" name="state" id="state" size="2" />
</div>
<div><label for="zip">*Zip</label>
<input type="text" name="zip" id="zip" size="5" />
</div>
</fieldset>
<br />
<fieldset>
<div><label for="contactperson">*Contact Person</label>
<input type="text" name="contactperson" id="contactperson" size="22" />
</div>
</fieldset>
<br />
<fieldset>
<div><label for="contactemail">*Contact Email</label>
<input type="text" name="contactemail" id="contactemail" size="23" />
</div>
</fieldset>
<br />
<fieldset>
<div><label for="phone">*Phone</label>
<input type="text" name="phone" id="phone" size="10" />
</div>
</fieldset>
<br />
<fieldset>
<div>
<label for="fax">Fax</label>
<input type="text" name="fax" id="fax" size="11" />
</div>
</fieldset>
<br />
<fieldset>
<div>
Please select the GISS session you plan to attend<P>
<input type="radio" name="session" id="giss1" value="GISS I"><?php print$giss1_status;?>
GISS I
<br />
<input type="radio" name="session" id="giss2" value="GISS II"><?php print$giss2_status;?> GISS II<br />
</div>
</fieldset>
<div class="centerac"><input type="submit" name="submit" id="submit" value="Submit to Enter Attendee Information" />
</div>
<br />
</div>
</form>
PHP
Code:
<?php
{
if(($_POST['college']=="")||($_POST['streetaddress']=="")||($_POST['city']=="")||($_POST['zip']=="")||($_POST['state']=="")||($_POST['contactperson']=="")||($_POST['contactemail']=="")||($_POST['phone']=="")||($_POST['fax']=="")||($_POST['giss1']=="")||($_POST['giss2']==""))
{
echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>";
if($_POST['college'] == ""){ echo "<li>*College</li>"; }
if($_POST['streetaddress'] == ""){ echo "<li>*Street Address</li>"; }
if($_POST['city'] == ""){ echo "<li>*City</li>"; }
if($_POST['zip'] == ""){ echo "<li>*Zip</li>"; }
if($_POST['state'] == ""){ echo "<li>*State</li>"; }
if($_POST['contactperson'] == ""){ echo "<li>*Contact Person</li>"; }
if($_POST['contactemail'] == ""){ echo "<li>*Contact Email</li>"; }
if($_POST['phone'] == ""){ echo "<li>*Phone</li>"; }
if($_POST['session'] == "unchecked") { echo "<li>You must select a GISS session</li>"; }
echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back</a> button and fill out these fields.</p></body></html>";
}
if ($selected_radio == 'giss1') {
$giss1_status = 'checked';
}
else if ($selected_radio == 'giss2') {
$giss2_status = 'checked';
}
if(isset($_POST['submit'])) {
$to = "my@email.com";
$subject = "Contact Has Registered";
$college = $_POST['college'];
$streetaddress = $_POST['streetaddress'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$contactperson = $_POST['contactperson'];
$contactemail = $_POST['contactemail'];
$phone = $_POST['phone'];
$selected_radio = $_POST['session'];
print $session;
}
$body = "From:$college
Street Address:$streetaddress
City:$city
State:$state
Zip Code:$zip
E-Mail:$contactemail
Phone Number:$phone
Contact Email:$contactemail
GISS Session:$selected_radio";
mail($to, $subject, $body);
$sendto = $_POST['contactemail'];
$ccto = "my@email.com";
$subject = "Registration";
$message = "Thank you for registering.
You are registered for:$selected_radio
College:$college
Address:$streetaddress
City:$city
State:$state
Zip:$zip
Contact Person:$contactperson
Contact Email:$contactemail";
if(mail($sendto, $subject, $message, $header)) header("location: attendee.html");
}
?>
<script type=text/javascript>
setTimeout("location.href='index.html'", [3000]);
</script>
Thanks, everyone for your help!
-
You're making this way too complex: read my posts carefully.
This has nothing to do with your existing code, nor is it intended to "solve" anything-- this is going to help you/us diagnose the problem.
Here's what you should do:
1. Ignore all of the PHP you have. Don't delete it, just don't use it for now.
2. Create a new php file called "phpnew.php"
3. In that file, paste exactly and only <?php print_r($_POST); ?> and NOTHING else.
4. Temporarily change the action of your HTML form to "....../phpnew.php" (the location of this new page).
5. Test it!!! Try different values in the form. See what the result is on the PHP page.
6. Find the pattern in the results from the radio buttons. What are you looking for? Is it "1" or "0"? Is it text? Is it being sent correctly? Then once you figure this out post the results here and we can try to help you figure out if the problem is in the PHP or in the HTML form.
This is a tool for diagnosing what is happening: it will tell us what data is actually being sent (and received by PHP) so we know what to do next.