slpctrl Posted December 20, 2007 Share Posted December 20, 2007 Can someone show me how I can add HTML forms on a php page, and only execute the php once the form information has been set? I know there's a particular order in which this must be done. And if anyone could explain why it must be done in that order, that'd be great! Thanks Quote Link to comment Share on other sites More sharing options...
papaface Posted December 20, 2007 Share Posted December 20, 2007 <?php if ($_POST) { //process code } else { echo 'HTML FORM HERE'; } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 I just posted this on another topic, it's a good tutorial for html forms and php. http://www.tizag.com/phpT/forms.php BTW, The very simple code papaface posted won't allow for any error checking and printing of such error messages, if you only show the form if it's not been posted. Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 20, 2007 Share Posted December 20, 2007 Try this <?php if(isset($_POST['submit'])) { print 'The form has been submitted'; } else { print '<form action=' . $_SERVER['PHP_SELF'] . ' method=post>'; print '<input type=submit name=submit value=Submit />'; print '</form>'; } ?> Quote Link to comment 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.