简体   繁体   中英

Why isn't my PHP form sending the information?

I'm trying to make a form in PHP that then passes the variables to the next page. My problem is that the drop down elements in my form aren't passing their values at all. When I do print_r($_GET) on the next page to see what values were passed through the form, only the inputs with type "text" or "radio" appear. I'm not sure what I'm doing wrong, as I've gotten this to work in the past. Can someone help me? I know that the variable names I'm pulling out of my MySQL queries are correct, as are the ids.

//begin form    
print "<form action = 'restaurant_confirm.php' method = 'GET'>";
print "Restaurant Name: <input type = 'text' size = 50 name = restaurant_name></br>";
// drop down for cuisine
print "Cuisine: <select>";
    while ($row = mysql_fetch_array($cuisine_result) ){
        print "<option name = 'cuisine' value = '".$row['cuisine_id']."'>". $row['cuisine_name']. "</option>";
    }
print "</select></br>";
// drop down form restaurant type
print "Restaurant Type: <select>";
    while ($row = mysql_fetch_array($type_result) ){
        print "<option name = 'restaurant_type' value = '".$row['type_id']."'>";
        print $row['restaurant_type'];
        print "</option>";
    }
print "</select></br>";
//Check boxes for price point
//table for alignment
print "Select one price point </br>";
print "<table>";
    //header row
    print "<tr>";
    print "<td>Price Point</td>";
    print "<td>Value</td>";
    print "<td>Select</td>";
    print "</tr>";
    while ($row = mysql_fetch_array($price_result)) {
        print "<tr>";
        //prints the price point
        print "<td>";
        print $row['price_point'];
        print "</td>";
        //prints the value
        print "<td>";
        print $row['price_value'];
        print "</td>";
        print "<td>";
        // radio button to choose
        print "<input type = 'radio' name = 'price_selection' value = ".$row['price_id'].">";
        print "</tr>";
    }

print"</table></br>";

//Check boxes for gluten type
//table for alignment
print "Select one gluten type</br>";
print "<table>";
    //header row
    print "<tr>";
    print "<td>Gluten Type</td>";
    print "<td>Select</td>";
    print "</tr>";
    while ($row = mysql_fetch_array($gluten_result)) {
        print "<tr>";
        //prints the gluten type
        print "<td>";
        print $row['gluten_type'];
        print "</td>";
        print "<td>";
        // radio button to choose
        print "<input type = 'radio' name = 'gluten_selection' value = ".$row['gluten_type_id'].">";
        print"</td>";
        print "</tr>";
    }

print "</table></br>";
//submit button
print "<input type = 'submit' value = 'Add'>";

print "";

Your select has no name, which is needed.

Change the selects to <select name="whatever"> and you will be able to get them via $_GET["whatever"] on the next page.

Your input and select fields do not have name parameter specified. name defines the variable name.

So <input name="blah" /> will be $_GET['blah']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM