ajicles Posted July 29, 2010 Share Posted July 29, 2010 I am trying to make my website submit a file when the submit button is pressed. I tried to use isset but when I press submit it doesn't work. This is just an example of when I am trying to do: <?php if (isset($_POST['submit'])) { echo "clicked"; } else { echo "not_clicked"; } ?> <form id="myform" enctype="multipart/form-data" action="test.php" method="POST"> <input type="submit" value="Upload" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/209190-on-submit/ Share on other sites More sharing options...
trq Posted July 29, 2010 Share Posted July 29, 2010 You have no form element named 'submit'. <form id="myform" enctype="multipart/form-data" action="test.php" method="POST"> <input type="hidden" name="submit"> <input type="submit" value="Upload" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/209190-on-submit/#findComment-1092457 Share on other sites More sharing options...
sniperscope Posted July 29, 2010 Share Posted July 29, 2010 I am trying to make my website submit a file when the submit button is pressed. I tried to use isset but when I press submit it doesn't work. This is just an example of when I am trying to do: <?php if (isset($_POST['submit'])) { echo "clicked"; } else { echo "not_clicked"; } ?> <form id="myform" enctype="multipart/form-data" action="test.php" method="POST"> <input type="submit" value="Upload" /> </form> Do something following. <?php if (isset($_POST['SubmitMe']) && $_POST['SubmitMe'] == 1){ echo "clicked"; } else{ echo "not_clicked"; } ?> <form id="myform" enctype="multipart/form-data" action="test.php" method="POST"> <input type="hidden" name="SubmitMe" value="1"> <input type="submit" value="Upload" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/209190-on-submit/#findComment-1092460 Share on other sites More sharing options...
newb Posted July 29, 2010 Share Posted July 29, 2010 or just do <input type="submit" name="submit" value="Upload" /> so you wont have to add a hidden line Quote Link to comment https://forums.phpfreaks.com/topic/209190-on-submit/#findComment-1092462 Share on other sites More sharing options...
trq Posted July 29, 2010 Share Posted July 29, 2010 or just do <input type="submit" name="submit" value="Upload" /> so you wont have to add a hidden line Some browser won't send that information. It's safe to use the hidden form or check for a field you know exists. Quote Link to comment https://forums.phpfreaks.com/topic/209190-on-submit/#findComment-1092463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.