graham23s Posted August 10, 2007 Share Posted August 10, 2007 Hi Guys, i have a button on a form just a basic one: <input name="submit" class="button" type="submit" value="Submit"> i tried to do: if (isset($_POST['submit'])) { echo 'DO CODE HERE!!'; include("includes/footer.php"); exit; } i dont want to actually do a form just execute the code once the submit button is pressed is that possible or do i need to do the <form action , method etc> code? thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/64313-solved-isset-post-question/ Share on other sites More sharing options...
lemmin Posted August 10, 2007 Share Posted August 10, 2007 The $_POST array doesn't receive the submit key and value unless it is sent to it using the POST method. There is no way for php to catch html events, (such as button presses) Javascript can, though. If you want to run php after a button is pressed, the button has to redirect to that php page, somehow. Quote Link to comment https://forums.phpfreaks.com/topic/64313-solved-isset-post-question/#findComment-320636 Share on other sites More sharing options...
d22552000 Posted August 10, 2007 Share Posted August 10, 2007 you would need <form action="code.php" method="post"> <!-- submit button here --!> </form> and have code.php with your second boxes code. Quote Link to comment https://forums.phpfreaks.com/topic/64313-solved-isset-post-question/#findComment-320639 Share on other sites More sharing options...
Fadion Posted August 10, 2007 Share Posted August 10, 2007 u can use isset() on another form element rather then the button, as its value is passed to the post superglobal only if the button is pressed. Usually people fill in data and just press enter which doesnt pass the button's value to post. Hope im clear with this lol. Quote Link to comment https://forums.phpfreaks.com/topic/64313-solved-isset-post-question/#findComment-320758 Share on other sites More sharing options...
graham23s Posted August 11, 2007 Author Share Posted August 11, 2007 hi guys, thanks for the input i totally missed out the fact to grab the POST data i needed to POST it first a moment of craziness there lol thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/64313-solved-isset-post-question/#findComment-320982 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.