derekbelcher Posted February 2, 2009 Share Posted February 2, 2009 I have a web at the following address: http://www.mercercountyfa.org/addentry.php I want to code this form so that the user enters the info and gets a preview before submitting the content to the database. Any help? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/ Share on other sites More sharing options...
Maq Posted February 2, 2009 Share Posted February 2, 2009 Any help? Thanks. Sure, make a button called "preview" that shows them what they typed in. Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/#findComment-752889 Share on other sites More sharing options...
derekbelcher Posted February 2, 2009 Author Share Posted February 2, 2009 Should I change the post to something other then my page that posts it directly to the database. What does the code look like for the preview button? Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/#findComment-752893 Share on other sites More sharing options...
Maq Posted February 2, 2009 Share Posted February 2, 2009 Make a preview button and at the top of your page you need something like: if(isset($_POST['preview'])) { echo "Here is your preview: "; //all of the inputs } Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/#findComment-752906 Share on other sites More sharing options...
derekbelcher Posted February 2, 2009 Author Share Posted February 2, 2009 Is this right? how do I list the inputs? Sorry, so many questions, I am very novice at PHP, trying to learn though :-) <?php if ($HTTP_POST_VARS['submit']) { mysql_connect("server info"); mysql_select_db("server info"); $entrytitle=$HTTP_POST_VARS['entrytitle']; $entrytext=$HTTP_POST_VARS['entrytext']; $query ="INSERT INTO weblog (entrytitle,entrytext)"; $query.=" VALUES ('$entrytitle','$entrytext')"; if(isset($_POST['preview'])) { echo "Here is your preview: "; $result=mysql_query($query); if ($result) echo "<b>Successfully Posted!</b>"; else echo "<b>ERROR: unable to post.</b>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/#findComment-752912 Share on other sites More sharing options...
derekbelcher Posted February 3, 2009 Author Share Posted February 3, 2009 I still don't know how to make this work. Can anyone help. I read somewhere about sessions, but have no idea how to set that up. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/#findComment-753262 Share on other sites More sharing options...
Gazan Posted February 3, 2009 Share Posted February 3, 2009 <?php //Your form goes here.. if(isset($_POST['preview'])) { echo "Here is a preview"; //Output the variables they filled in.. echo $title; echo $weblog_entry; } ?> Replace the variables with whatever variables you're using. It's not as hard as it seems. You just take the variables they've filled in, and then output them on the same page IF they've pressed "preview". EDIT: what maq said. Quote Link to comment https://forums.phpfreaks.com/topic/143521-need-help-coding-a-web-form/#findComment-753530 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.