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
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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.