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 Link to comment https://forums.phpfreaks.com/topic/82445-solved-html-forms-within-a-php-page/ 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/82445-solved-html-forms-within-a-php-page/#findComment-419177 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. Link to comment https://forums.phpfreaks.com/topic/82445-solved-html-forms-within-a-php-page/#findComment-419180 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>'; } ?> Link to comment https://forums.phpfreaks.com/topic/82445-solved-html-forms-within-a-php-page/#findComment-419181 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.