Hicham Harmaz
Hicham Harmaz

Reputation: 51

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>

Upvotes: 0

Views: 1819

Answers (1)

Ralph
Ralph

Reputation: 337

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">

Upvotes: 1

Related Questions