I am trying to submit a form and after submission, the webpage does not go to a different page. Here are some of the resources that I've looked at: php form - on sumbit stay on same page and php and html form on the same page. However, none of their solutions seemed to fully work, namely, it helped me figure out how to stay on the same page by putting the PHP code in the same file as the HTML but it is not "echoing" any message on the website so I'm not sure if the PHP is actually working. So here is my code:
<!DOCTYPE html>
<html>
<body>
<form method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
<?php
if(isset($_POST['submit']))
{
echo "yo! what up homie?!";
}
else
{
// Display the Form and the Submit Button
}
?>
</body>
</html>
After uploading a file and submitting it, the webpage does not go to a different page. However, it is not echoing yo! what up homie?!
. Any suggestions on how to stay on the same page AND echo the message after the user presses the submit button?