Welcome! Log In Create A New Profile

Advanced

clear text box value after submit

Posted by 77517296 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
clear text box value after submit
September 05, 2012 04:26PM
Hi Guys, Can any one help me. After inserting a value form a textbox to mysql db. the value remains (not sure how) but when I refresh the page (with the text box being empty now) it keeps entering the value provided at the start.
avatar Re: clear text box value after submit
September 05, 2012 07:46PM
Hay

in your script you prob have
Language: PHP
value="<?PHP print $uname;?>"
in your textbox which retrieve that last value. Are you using checks to see whether your button is clicked to process your form? as in the
Language: PHP
isset($_REQUEST[';POST';])
with some conditional logic(if statements)?
Re: clear text box value after submit
September 05, 2012 11:00PM
Could be a cache thing with the browser or a setting ... You could write a small Javascript reset function to clear the front end or as 77726812Lancevjm said you could do conditional logic if you are echoing out the values into the fields ... Are you outputting to the fields? If not then its most likely a browser setting ... What browser are you using? PHP by nature runs in the background and runs from top to bottom once as the page loads, so usually cahce-ing isn't too much of an issue with PHP ... Let's see your code?
Re: clear text box value after submit
September 05, 2012 11:03PM
Side note for those who use chrome a lot as a dev environment, the auto-fill feature can help you breeze though forms, can even save different auto-fill profiles / values ... A good browser, firefox is also up there but sadly no auto-fill feature built into it ...
Re: clear text box value after submit
September 06, 2012 09:25AM
Language: PHP
<html> <title>Manage Courses</title> <head>   </head> <?php include';config.php';;   $course = " ";     if(isset($_POST[';submit';])) { $course = $_POST[';course';]; $course = htmlspecialchars($course);   $SQL = mysql_query("INSERT INTO course(cname) VALUES(';$course';)"); echo "course " .$course . " added succesfully"; } else { echo "enter new course"; } ?>   <body>   <FORM NAME ="form1" METHOD ="POST" ACTION ="course_man.php"> Course Name: <INPUT TYPE = ';TEXT'; Name =';course'; value = " " size = ';25';> <P> <INPUT TYPE = "Submit" Name = "submit" VALUE = "Save"> </P> </FORM>   </body> </html>
Re: clear text box value after submit
September 06, 2012 11:40AM
Hi Guys, Thanks for your efforts I've managed to find solution to this issue. The problem was that the cache memory wasn't cleared after the "submit" button.
So now I am refreshing the page after every "submit" event with the simple
Language: PHP
header(';location: mypage.php';);
Re: clear text box value after submit
September 06, 2012 11:59AM
No worries ... Seems a bit excessive to do a header redirect with PHP just to clear the form though?
Re: clear text box value after submit
September 06, 2012 02:52PM
The major issue here was that , the information was inserted every time you refresh the page (and I did not want those duplicate records).
Sorry, only registered users may post in this forum.

Click here to login