date text field resets on click back

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>
chewonthatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

marko020397Commented:
I believe the problem is in your date popup control. It resets the date whenever the user comes to the page.
0
carchitectCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chewonthatAuthor Commented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

chewonthatAuthor Commented:
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
chewonthatAuthor Commented:
i'v been fooling around with it awhile and your definately on the right track
0
chewonthatAuthor Commented:
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
carchitectCommented:
i am sorry could not respond to ur comments as my hotmail account is not working...
sorry for the delay...
regards
0
chewonthatAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.