简体   繁体   中英

Getting 404 not found code after submitting form

I have a assignment due to tomorrow and cant find the solution. After submitting getting a 404 not found code back. Html and php code are in the same file.

<?php
if (isset($_POST['submit']))
    {
    if (isset($_POST['subject']))
    {
        foreach ($_POST['subject'] as $subject)
            echo '<img src="img/' . $subject . '.jpg">';
    }
    else
        echo "Select a car of your choosing!";
}
?>

<html lang="en">
<body>
<form method='post'>
    <select name="subject" multiple size=4>
        <option value='Ferrari'>Ferrari</option>
        <option value='Lambo'>Lambo</option>
        <option value='Audi'>Audi</option>
        <option value='VW'>VW</option>

    </select>
    <input type="submit" name="submit" value=Submit>
</form>
</body>
</html>

You haven't enclosed the value of your submit button. Also change the form code to what I posted below, this should fix your issue.

FROM:

<form method="post">
<input type="submit" name="submit" value=Submit>

TO:

<form action="" enctype="multipart/form-data" method="POST">
<input type="submit" name="submit" value="Submit">

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