Hi there,
I'm trying to create a form with radio or multiple options. But I want to set 'value=$str' for each radio button with say, $str="please work this time", rather than an explicit string like 'value="please work this time"'.
Unfortunately, all that gets passed is the first word of the string.
Here's the form and processing script:
<?php
if ($_POST['action'] == 'submitted') {
print '<pre>';
print_r($_POST);
print '<a href="'. $_SERVER['PHP_SELF'] .'">Please try again</a>';
print '</pre>';
} else {
$str="stuttgarter Schwab";
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Name: <input type="text" name="personal[name]"><br>
Email: <input type="text" name="personal[email]"><br>
Beer: <br>
<select multiple name="beer[]">
<option value="warthog">Warthog</option>
<option value="guinness">Guinness</option>
<option value=<?php echo $str ?>>Stuttgarter Schwabenbräu</option>
</select><br>
<input type="hidden" name="action" value="submitted">
<input type="submit" name="submit" value="submit me!">
</form>
<?php
}
?>
When I choose the '$str' option, all that gets passed is the first word.Here's the output:
Array
(
[personal] => Array
(
[name] => steve
[email] => btfd
)
[beer] => Array
(
[0] => stuttgarter
)
[action] => submitted
[submit] => submit me!
)
Please try again
Thanks for your time,
mrob.