PHP Help, trying to get a whole php code in one if statment but isnt working properly?

lord unforgiven

New member
i have a radio button in html and i want the different php scripts to be displayed depending on what radio button is chosen like

<html>
<body>
<input type="radio" name="radio1" value="php1/> php1
<input type="radio" name="radio1" value="php2/> php2

<?php
$radio1 = ($_POST["radio1"]);
if ($radio1 == "php1"){
echo "php1";
}
if ($radio1 == "php2"){
echo "php2";
}
?>
</body>
</html>
that was just a quick code i typed out of my head the code i am working with atm is

<html>
<body>
<input type="radio" name="display" value="c"/> display
<input type="radio" name="display" value="a"/> display
<input type="radio" name="display" value="d"/> display
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" value="Submit" name="submit"/>
<?php
$display = ($_POST["display"]);
if (isset($_POST["submit"])) {
if ($display == "a" ) {
echo "hello";
echo '<html> <body><input type="radio" name="wow" calue="o"/> heojsgs </body> </html>';
}else{
echo "error";
}
}
?>
</body>
</html>

and im trying to get it to work so i can use it on an even bigger php code
 
In addition to what the other guy said about closing quotes, you also need to put the input elements inside of a form container with method="post". You also need to include a submit element in your form.

This a good way to experiment with php, but you really should use a framework (like Zend, Cake PHP, or Kohana) to separate concerns about presentation from your business logic -- it's best to develop good web development practices from the beginning, I think.

ETA:
You're closer. you need to move the form element ABOVE the radio buttons. Your php logic is fine. You just need to brush up on html.
 
Back
Top