Wednesday, 11 September 2013

PHP radio button

PHP radio button

Ok so Im trying to use radio buttons in my PHP code. I wrote a Madlib in
PHP and I want to write in a radio button that when a user selects it, it
will change the story etc. Happy ending or sad ending here the code I have
so far. Any help would be appreciated.
<html>
<head>
<title>James Nygaard's Mablib</title>
</head>
<body bgcolor="<?php echo $bg; ?>" text="<?php echo $fg; ?>">
<h1 style="font-family:cursive;">Create your Madlib below:</h1>
<form action="" method="post">
Enter the name of a boy:
<input name="noun1" type="text" value="<?= $_POST['noun1'] ?>"
/><br />
Enter an Adjective that describes a person:
<input name="adj1" type="text" value="<?= $_POST['adj1'] ?>"
/><br />
Enter the name of a man:
<input name="noun2" type="text" value="<?= $_POST['noun2'] ?>"
/><br />
Enter an Adjective that describes a person:
<input name="adj2" type="text" value="<?= $_POST['adj2'] ?>"
/><br />
Enter the name of a woman:
<input name="noun3" type="text" value="<?= $_POST['noun3'] ?>"
/><br />
Enter your favorite animal:
<input name="noun4" type="text" value="<?= $_POST['noun4'] ?>"
/><br />
Enter a name:
<input name="noun5" type="text" value="<?= $_POST['noun5'] ?>"
/><br />
Enter the name of your favorite city:
<input name="noun6" type="text" value="<?= $_POST['noun6'] ?>"
/><br />
Enter a feeling that ends in "ness":
<input name="adj3" type="text" value="<?= $_POST['adj3'] ?>"
/><br />
Enter a Verb that ends in "ing":
<input name="verb2" type="text" value="<?= $_POST['verb2'] ?>"
/><br />
Enter the name of a boy:
<input name="noun7" type="text" value="<?= $_POST['noun7'] ?>"
/><br />
Enter the name of a girl:
<input name="noun8" type="text" value="<?= $_POST['noun8'] ?>"
/><br />
<input type="submit" value="Click here or press enter to see
your MadLib" /><br />
</form>
<div style="color: #2F4F4F; font-family: cursive;">
<?php
$bg = "8FBC8F";
$fg = "2F4F4F";
if(isset($_POST['noun1'])) {
echo "<h1> The adventures of {$_POST['noun1']}. </h1>";
echo "This is where i will put the story. I already have
the story but the code is really long so I left it out
of this question.";
echo "<br> The end.";
}
?>
</div>
</body>
</html>

No comments:

Post a Comment