Jump to content

[SOLVED] Radio Buttons Driving me Insane!!


Cetanu

Recommended Posts

Okay, I've tried fixing this forever! I thought I had a handle on forms and PHP. >.> <.<

 

I would like this:

 

1) Member comes to page.

 

2) Answers yes or no (via Radio Form)

 

3) Depending on choice, header to new location. (via if...elseif...else )

 

It won't work! Nothing happens!!!!! No header. Nothing. >.> <.< I think it's because I'm using radio buttons.

<form action="rpgtest.php" method="post"> 
<fieldset> 
<legend>Do You Have a Character?</legend> 
<input type="radio" name="Pos" id="yes" value="Yes"/>Yes, I do.<br/>
<input type="radio" name="Pos" id="no" value="No"/>No, I need one!<br/> <br/> 

<input type="submit" name="submit" id="submit" value="Go!"/>
</fieldset> 
</form> 

<?php
if($_POST['yes'] && $_POST['submit']){
header('Location: http://mythscape.freezoka.com/chrisrpg/'); 
} 
elseif($_POST['no'] && $_POST['submit']){ 
header('Location: http://mythscape.freezoka.com/chrisrpg/create.php'); 
}
else { 
echo "After selecting a choice you will be redirected to the appropriate page.";
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/171051-solved-radio-buttons-driving-me-insane/
Share on other sites

Now I get the white screen of doom.  :shy:

<form action="rpgtest.php" method="post"> 
<fieldset> 
<legend>Do You Have a Character?</legend> 
<input type="radio" name="Pos" id="yes" value="Yes"/>Yes, I do.<br/>
<input type="radio" name="Pos" id="no" value="No"/>No, I need one!<br/> <br/> 

<input type="submit" name="submit" id="submit" value="Go!"/>
</fieldset> 
</form> 

<?php

if($_POST['Pos'] == "Yes"){
header('Location: http://mythscape.freezoka.com/chrisrpg/'); 
}

elseif($_POST['Pos'] == "No"]){ 
header('Location: http://mythscape.freezoka.com/chrisrpg/create.php'); 
}

else { 
echo "Invalid choice. Try again.";
} 
?>

 

 

EDIT: NEVERMIND.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.