Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

date text field resets on click back

Posted on 2003-02-19
8
Medium Priority
?
367 Views
Last Modified: 2006-11-17
i have a form.php that is sent to a form handler.php where the user can look over the data before submission.  if the user want's to change/alter the data then he can click back.  the only problem is that the date input is reset and no longer there, making him have to use the popup date calendar all over agan; that is if he even notices that the date has reset since all the other inputs are still there.

i use this at the top of the form processor.php if it helps
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix for the same problem

i have included below the form.php date field and calander pop ref, if u need more let me know.  also if possible i would like it to work in all browswers.

good luck,


<input name="date" type=text id="date" onFocus="javascript:blur();" value="click icon to get date>" size="22" readonly>
<a href="javascript:;" onClick="KW_doCalendar('txtName',0)"><img src="help.gif" width="24" height="24" border="0"></a>
0
Comment
Question by:chewonthat
  • 5
  • 2
8 Comments
 
LVL 4

Expert Comment

by:marko020397
ID: 7985901
I believe the problem is in your date popup control. It resets the date whenever the user comes to the page.
0
 
LVL 6

Accepted Solution

by:
carchitect earned 200 total points
ID: 7985996
yes it will reset as the solutio is
when you execute your form first time.... use some session field as


use this code before going to main form.......
<?
session_start();
$ses_date="Click icon to get date";
session_register('ses_date');
?>


Main Form.......
<?
session_start();
?>
<input name="date" type=text id="date" onFocus="javascript:blur();" value="<?=$_SESSION['ses_date']?>" size="22" readonly>
<a href="javascript:;" onClick="KW_doCalendar('txtName',0)"><img src="help.gif" width="24" height="24" border="0"></a>


Form Handler.........
Now here set
<?
session_start();
$_SESSION['ses_date']=$_POST['date'];
?>
Then...Form Handler Code.....



Now.......even if you go back to main form...now your main from will contain the date which user selected when he entered form data fro the first time....



Regards
0
 

Author Comment

by:chewonthat
ID: 7990959
hi, thanks, i tried it in the page before my form and got the following:
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

i wouldn't have a clue how to disable.

is there anyway i can just assign the value in the form.php (as you call it Main form)?  instead of putting code before the main form?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:chewonthat
ID: 7991018
this might help, here is my formhandler
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix

         
// Get the user's input from the form
     $date = $_POST['date'];


// Create a new Session Value
  session_register('date');
       
// Register the input with the value
  $_SESSION['date'] = $date;

         
$enter_to_db = <<<PUT_IN
<?
PUT_IN;

          // save all the globals to a text file...
        foreach ($_POST as $word => $val) {
           $enter_to_db .= "\$$word:::$val\n";
        }

      // save all the globals to a text file...
        foreach ($_GET as $word => $val) {
           $enter_to_db .= "\$$word:::$val\n";
        }

$enter_to_db .= <<<PUT_IN
?>
PUT_IN;

        $rand = rand(1,999);

        $put = @fopen("$rand.ses", "w+");
        fputs ($put, $enter_to_db);
        fclose($put);

       
// Display the sssion information:

<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method=POST id=form1 name=form1>
 the date of your call, <strong><? echo $_SESSION['date']; ?>            
</form>
</body>
0
 

Author Comment

by:chewonthat
ID: 7991073
i'v been fooling around with it awhile and your definately on the right track
0
 

Author Comment

by:chewonthat
ID: 7991157
took me awhile but i got it thanks to your lead.  i gues you have to have the php before form.php, won't this just fill up my server space with useless sessions data, if  users just want's to look at the form?

pre main form

<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$date="Click icon to get date";

// Create a new Session Value
 session_register('date');
     
// Register the input with the value
 $_SESSION['date'] = $date;

main fom

<input name="date" type=text id="date" STYLE="color:gray"
onFocus="javascript:blur();" onMouseOut="this.style.color='black'"
value="<? echo $_SESSION['date']; ?>"  size="22" readonly>
0
 
LVL 6

Expert Comment

by:carchitect
ID: 8031920
i am sorry could not respond to ur comments as my hotmail account is not working...
sorry for the delay...
regards
0
 

Author Comment

by:chewonthat
ID: 8067435
no problem, now a new problem has come up, (of course) i took your advice and it works fine for normal inputs but how do i keep radio buttons and drop down lists from reseting on click 'back'

<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$date="Click icon to get date";

// Create a new Session Value
session_register('date');
     
// Register the input with the value
$_SESSION['date'] = $date;

main fom

<input name="date" type=text id="date" STYLE="color:gray"
onFocus="javascript:blur();" onMouseOut="this.style.color='black'"
value="<? echo $_SESSION['date']; ?>"  size="22" readonly>
<input type="radio" value="day" checked name="option">
        10am-12pm through 1-4pm
        <input type="radio" value="evening" name="option">
        5-10pm</font> </td>
<select name="hour" size="1" id="select6">
          <option>05am</option>
          <option>06am</option>
          <option>07am</option>
          <option>08am</option>
          <option>09am</option>
          <option>10am</option>
          <option>11am</option>
          <option>12pm</option>
          <option>01pm</option>
          <option>02pm</option>
          <option>03pm</option>
          <option>04pm</option>
          <option>05pm</option>
          <option>06pm</option>
          <option>07pm</option>
          <option>08pm</option>
          <option>09pm</option>
        </select>
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question