View Full Version : Help - Converting values

10-28-2009, 07: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>
<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">

This is the process.php code:


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

10-28-2009, 08:35 AM
I'm just now learning how to get information from one page to another. So I'm using a script that I found and modifying it to where instead of using checkboxes I can receive info from text input and receive only that which was entered and submitted

10-28-2009, 08:44 AM
while (list ($key,$val) = @each ($hworder)) {
echo "$val,";

just try this to see if it is printing values for the checkboxes or not?

10-28-2009, 10:07 AM
I'm not looking for set values as a check box would have I'm needing to extract values that are input as in through a text box

10-29-2009, 07:12 AM
thats just it i'm not wanting to use checkboxes i want to know how to use text boxes where i can recieve data input from a form and data that is all readly set. i just don't know how to format the php to recieve it