PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 7th, 2002, 02:33 AM
stevesoler stevesoler is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 6 stevesoler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
HTML form preview then INSERT using PHP & MySQL

Hello everyone! This is regarding HTML forms, PHP & MySQL.

My Question:

How do you create an html form that goes to a preview screen and then allows the user to move back to the form if they made any errors and corrections are needed or click the send button to submit the form. The form's contents are then inserted into a database table.

Reply With Quote
  #2  
Old July 7th, 2002, 04:01 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: HTML form preview then INSERT using PHP & MySQL

JavaScript works well for this. The function to use, if I remember correctly, is confirm().

Hope that helps.

Reply With Quote
  #3  
Old July 7th, 2002, 04:06 AM
stevesoler stevesoler is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 6 stevesoler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: HTML form preview then INSERT using PHP & MySQL

Thanks but I don't know Javascript.

I'm just learning PHP, MySQL, SQL. This is all new to me. I do know HTML though (big deal).

The actions I want the user to take are as follows:
1) Fill out form.
2) Press Preview Button (the only button on that page).
3) Look over preview of text entered. (this should be on a new page and appear as text, not text in form fields.)
4a) If user finds mistake in text of Preview, click Edit button (or link or Browser back button) to go back to form and make changes. Then user repeats steps 1 (editing not re-entering data) through 4.
4b) If user does not find mistakes in text of Preview, clicks submit button that INSERTS form data into MySQL table.
5) User gets a new page thats says "thank you. form submitted."

Does anyone know how I can get this to work?

I already know how to INSERT form data into a table and ECHO the data onto a page after the data was inserted, but I can't figure out how to add the Preview in the middle before inserting the data.

Thanks!

Reply With Quote
  #4  
Old July 7th, 2002, 04:29 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: HTML form preview then INSERT using PHP & MySQL

OK, well believe it or not you already know the "skills" to make this happen. Plus you already have defined the flow of things.

To create the page in the middle all you have to do is ECHO it back to the user in a non-form fields, like you said. But also ... when generating the html for this middle _DO_ create a form with input types as HIDDEN. Now when the user decides that the info is accurate and presses the SUBMIT button you can retrieve the data like you normally would from a form and insert it into your db.

I hope that makes sense.

Reply With Quote
  #5  
Old July 7th, 2002, 04:47 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: HTML form preview then INSERT using PHP & MySQL

This is what the code would look like:

php Code:
Original - php Code
  1.  
  2. // firsthtmlpage.htm
  3. <html>
  4. <body>
  5. <form method=post action="preview.php">
  6. Name: <input type=text size=20 name="name">
  7. <input type=submit>
  8. </form>
  9. </body>
  10. </html>


php Code:
Original - php Code
  1.  
  2. // preview.php
  3. <html>
  4. <body>
  5. Confirm this is accurate.<p>
  6. Name: <? echo $_POST['name'] ?>
  7. <form method=post action="save.php">
  8. <input type=hidden name="name" value="<? echo $_POST['name'] ?>">
  9. <input type=submit>
  10. </form>
  11. </body>
  12. </html>


php Code:
Original - php Code
  1.  
  2. // save.php
  3. <?
  4.   // insert data into db
  5. ?>
  6. <html>
  7. <body>
  8. Thank you. Form submitted.
  9. </body>
  10. </html>

Reply With Quote
  #6  
Old July 7th, 2002, 06:27 AM
stevesoler stevesoler is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 6 stevesoler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: HTML form preview then INSERT using PHP & MySQL

EvilivE,

I did as you suggested, which by the way makes perfect sense. I'm sorry i could not figure that out. But I did get a error after submitting the form to preview.php, I must be doing some thing wrong.
Here is the error I got:
Parse error: parse error in /public/ContactUs/preview.php on line 29
Here are lines 28 and 29:
<form method="POST" action="save.php">
<input type=hidden name="First_Name" value="<?Â*echoÂ*$_POST['First_Name']Â*?>">

What do you think could be wrong?

Thanks for your help!!!!
- steve

Reply With Quote
  #7  
Old July 7th, 2002, 09:20 AM
stevesoler stevesoler is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 6 stevesoler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: HTML form preview then INSERT using PHP & MySQL

I figured it out! Since i had copied code from a forum web page, it some how copied over some invisible characters into my code. They can only be seen if i turn on the show invisibles feature of my text editor. Well, I took them out and then the code worked.

Thanks so much for all your help EvilivE!
You really saved the day!!!!

Take care.
- Steve

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > HTML form preview then INSERT using PHP & MySQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway