Save data in input fields when they press "BACK BUTTON"

Posted on 16th Feb 2014 07:03 pm by admin

Hi, this is html form: And let's say they get a error "Please enter ur title must be more then 3 character" then they click the BACK BUTTON AND ALL THERE DATA IS GONE!!

How i fix?

Code: <form action="u.php" method="post">
<INPUT TYPE=hidden NAME=name VALUE="<?php echo $_SESSION['user_name']; ?>">
<fieldset class="in" style="width:804px">
<legend>Submit Prayer</legend>
<div class="p9 ce">
<?php echo $l; ?>
Welcome, Please fill out the Prayer form and it will be submited into the Prayer Center!
<table class="ftbt">
<td align="right" width="25%">Prayer Title:</td>

<td><input type="text" name="title" value="" size="30" maxlength="50"/></td>
<?php echo $pray; ?>
<td align="right">Level of Prayer:</td>
<td class="cL"><select name="level">
<option value="1">Please God Right Now</option>
<option value="2">In a Few Minutes</option>
<option value="3">Maybe today</option>
<option value="4">Sometime this Week</option>
<option value="5">In a couple of Years</option>
<option value="6">Whenever you want</option>

<td align="right" valign="top">Prayer:</td>
<td><textarea name="prayer" cols="88" rows="11"></textarea></td>
<tr class="bts ce"><td colspan=2><b>Security Code Confirmation</b></td></tr>

<td align="right">Your unique security code<input type="hidden" name="secId" value="76c2b0e6f20ed0f1b209bcf39dee8e06"></td>
<img src="php_captcha.php">

<span class="desc">If The images are broke, please contact us.</span></span>

<td align="right" >Confirm security code:</td>
<td><input type="text" size="3" maxlength="5" name="number" />
<span class="desc">Please Enter the 3 Digit code above, Only Numbers are allowed.</span></td>
This is my PHP u.php

Code: <?php
include 'dbc.php';
header('private, must-revalidate');
if (!isset($_SESSION['user_id'])) {
$e = "";
$title = $_POST['title'];
$text = $_POST['prayer'];
$time = date("D, M j Y, h:ia");
$name = $_POST['name'];
if(trim($_POST['title'])=='' || strlen(trim($_POST['title'])) > 30 || strlen(trim($_POST['title'])) > 30){
echo "Please enter a Title between 3 and 30 characters!<br />"; //concatenate the $error Message with a line break
//maybe dont need $private = $_POST['private'];
if(trim($_POST['name']) > 20){
echo "Please enter a username between 3 and 20 characters!<br />"; //concatenate the $error Message with a line break

$number = $_REQUEST['number'];
echo '<center><font face="Verdana, Arial, Helvetica, sans-serif" color="#FF0000">
Validation string not valid! Please try again!</font></center>';



if (!isset($_SESSION)) {
// anti flood protection
if(isset($_SESSION['lol']) && $_SESSION['lol'] > time() - 30){
// users will be redirected to this page if it makes requests faster than 2 seconds
echo "Stop flooding please";
$_SESSION['lol'] = time();
mysql_query("INSERT INTO `prays` (`title`,`prayer`,`time`,`level`,`nameid`,`name`) VALUES (
'". mysql_real_escape_string($_POST['title']) ."',
'". mysql_real_escape_string($text) ."',
'". mysql_real_escape_string($time) ."',
'". mysql_real_escape_string($_POST['level']) ."',
'". mysql_real_escape_string($e) ."',
'". mysql_real_escape_string($name) ."');") or die(mysql_error()) ;


No comments posted yet

Your Answer:

Login to answer
312 Like 41 Dislike
Previous forums Next forums
Other forums

I have a variable in my PHP script like


License Issue - service type user

I would like to understand the following issue regarding sap license.
I wish to

Help with setcookie()
Merry Xmas to those on this foruum
Older guy here with some experience but not allot so please be

Oracle11g Patch issue
Hi all,

I'm getting the following error while installing Oracle11g Patch on IBM-AI

contact form - output to page and email
I have the following in my controller:

$message['name'] = htmlentities(strip_tags(trim($_POST

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS

Play Free Quiz and Win Cash