简体   繁体   中英

PHP: passing values of select and hidden input via image submit button

I have a table contains Orders data that was retrieved from a data base and there is a field called "status" contains a form with select options and a hidden input with the value of the order ID.. the issue that the form doesn't seem passing the data to the php file that will run the function.

I tried both POST and GET methods and what I noticed that the data are passed in the URL leading to the php file but with blank page.

this is the URL to show the parameters:

http://localhost/project_name/test2.php?submit.x=15&submit.y=22&status=new&orderId=190406053842

here is my HTML form

<td>
        <form action="test2.php" method="GET">
        <input type="image" name="submit" src="icons/submit.png" alt="Submit" style='width:30px;height:30px;border:0;' onclick="confirm('are you sure?')"> 
        <select name="status">
            <option value="new">new</option>
            <option value="checking">checking</option>
            <option value="processing">processing</option>
            <option value="done">done</option>
          </select>
          <input type="hidden" name="orderId" value="<?php echo $row["ORDER_ID"]; ?>">
          </form>
</td>

this is the php file (just echoing the result to make sure it works and proceed onwards)

    <?php
    $db = mysqli_connect('localhost', 'root', '', 'project_name');


            if(isset($_GET['submit'])){
                $status = $_GET['status'];
                $ID = $_GET['orderId'];

    echo $staus;
    echo $ID;
}
    ?>  

thank you.

If you look at your GET URL string there is no 'submit' variable, so checking for a 'submit' variable is not going to work.

It looks like it is appending co-ordinates to the 'submit' variable so its actually outputting 'submit.x' and 'submit.y'. I've never used the image input type before so can only guess this is the intended functionality of this input type.

You could get around this by checking for the 'orderID' instead of 'submit'. Or you could try 'submit.x' or 'submit.y'.

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