ghost2012
10-28-2009, 06:37 AM
Need help converting the code where it will accept and process
inputs from checkbox to text
This is the html code:
<form action="process.php" method="post">
<p>What is your name?</p>
<p><input type="text" name="customer_name"></p>
<p>What orders do you want?</p>
<p>
<input type="checkbox" name="hworder[]" value="order01"> Order01
<br />
<input type="checkbox" name="hworder[]" value="order02"> Order02
<br />
<input type="checkbox" name="hworder[]" value="order03"> Order03
<br />
<input type="checkbox" name="hworder[]" value="order04"> Order04</p>
<input type="submit">
</form>
This is the process.php code:
<?php
$hworder = $_POST["hworder"];
$customer_name = strval($_POST["customer_name"]);
if (is_array($hworder)) {
foreach ($hworder as $key => $value) {
print "$customer_name ordered $value .<br>";
}
}
?>
It processes the checkboxes with no problem when I convert to text and try to get only values that I've submitted. Instead of receiving all.
Ok thats where I'm at.
Help please.
inputs from checkbox to text
This is the html code:
<form action="process.php" method="post">
<p>What is your name?</p>
<p><input type="text" name="customer_name"></p>
<p>What orders do you want?</p>
<p>
<input type="checkbox" name="hworder[]" value="order01"> Order01
<br />
<input type="checkbox" name="hworder[]" value="order02"> Order02
<br />
<input type="checkbox" name="hworder[]" value="order03"> Order03
<br />
<input type="checkbox" name="hworder[]" value="order04"> Order04</p>
<input type="submit">
</form>
This is the process.php code:
<?php
$hworder = $_POST["hworder"];
$customer_name = strval($_POST["customer_name"]);
if (is_array($hworder)) {
foreach ($hworder as $key => $value) {
print "$customer_name ordered $value .<br>";
}
}
?>
It processes the checkboxes with no problem when I convert to text and try to get only values that I've submitted. Instead of receiving all.
Ok thats where I'm at.
Help please.