473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

retain form data

1
Hi,

I am very very new to web programming and I want to retain data once the form is submitted. I tried other says but no luck. Could someone point it out for me please?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start(); // Start the session where the code will be stored.
  3. ?>
  4.  
  5. <html>
  6.  
  7. <head>
  8. <title>Securimage Test Form</title>
  9. </head>
  10.  
  11. <body>
  12.  
  13. <?php
  14. if (empty($_POST)) { ?>
  15.  
  16. <form method="POST" >
  17. <strong>Name:</Strong><br />
  18. <input id="text" name="usname" />
  19. Code:<br />
  20. <input type="text" name="code" size="12" /><br /><br />
  21.  
  22. <input type="submit" value="Submit Form" />
  23. </form>
  24.  
  25. <?php
  26. } else { //form is posted
  27. echo "<center>Sorry, the code you entered was invalid. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
  28. if (isset($_POST[username])) return $_POST[username];
  29. }
  30. ?>
  31. </body>
  32. </html> 
Dec 18 '09 #1
1 2587
kovik
1,044 Expert 1GB
Instead of printing only an error message, also print the form and make use of the value attribute of the <input> element. You'll want to set it to the data inside of the $_POST array.
Dec 18 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pete | last post by:
Just a quick question regarding the way to do something rather than the actual code :- I have a page which has some links that go through to a HTML form and each link will check a certain...
1
by: Jitendra Shinde | last post by:
I am having 14 textboxes on the form and One data grid control and one Button That button allows to open new web page (in new window) where in I can select some products from the list. The...
2
by: kevin carter | last post by:
Hi we have a form that accepts inputs from the user at the end of the day the data that has been input is stored on a table,(all textboxes are bound to the table) THe next day a clear form is...
1
by: SorboPos | last post by:
Hi. I have a form with continuous forms and a data entry section in the header of the form. (I.e. all transactions show in the main form area like a data sheet and the data for the highlighed...
3
by: ANTISPAM_garycnew_ANTISPAM | last post by:
What is the simplest way to retain the last option value selected in an html select object using javascript? I am currently using a server-side cgi language to accomplish this task, but it adds...
6
by: Ian Davies | last post by:
Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you can understand whats happening. First my script is below. Have a look and I'll explain at the bottom what it...
5
by: teerock | last post by:
Hello fellow PHPers, I am relatively new to PHP but have come a long way in a short time and consider myself a fast learner. My application requires the user to enter information into forms on a...
2
by: farukcse | last post by:
Dear sir, i am using below of this code for searching and viewing data from database. <form name='search_form' method = 'POST' action='' > <input type=text name='id_no' value='' maxlength='10'...
3
by: raaman rai | last post by:
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation. When i add the information from a form, i retain the form values in the following way incase...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.