0

in my project I need to take the value of selected link from one page to another page and it should be display in the textbox.

for this i have used session variable code is as below :

in caledar.php

This is not the entire script ... there is one class which generates the calendar code. below is the function.

function getDateLink($day, $month, $year)
        {
            // Only link the first day of every month
            $link = "";
            if ($day)
            {
                $selectedDate = $day.$month.$year;
                var_dump($selectedDate);die;
                //session_register("$selectedDate");
                //session_start();

                if (isset($_GET["selectedDate"]))
                $_SESSION['date'] = $selectedDate;

                //("location:login_sucessful.php");

                $link = "Leave_app.php";
            }
            return $link;
    }

in application.php

<input type="text" id="Editbox1" name="strt_date" value="<?PHP
if(isset($_SESSION['date'])){echo $selectedDate;}?>">

It is not working. also not receiving any error message.

5
  • What is not working? What is this supposed to do? If this is your entire script, you have no definitions of any of the variables on the first line. Commented Oct 21, 2012 at 21:14
  • Where are you assigning $day, $month and $year? Commented Oct 21, 2012 at 21:14
  • Make sure that $selectedDate contains a correct date. You can check this by putting var_dump($selectedDate);die; in caledar.php just after you assign $selectedDate Commented Oct 21, 2012 at 21:16
  • This is not the entire script ... there is one class which generates the calendar code. below is the function. Commented Oct 21, 2012 at 21:21
  • Hi Pinouchon, i used var_dump($selectedDate);die; and the output is "string(6)112012" Commented Oct 21, 2012 at 21:31

1 Answer 1

1

You're not echoing the actual $_SESSION variable, it would need to be done like this:

<input type="text" id="Editbox1" name="strt_date" value="<?PHP if(isset($_SESSION['date'])){echo $_SESSION['date'];}?>">
Sign up to request clarification or add additional context in comments.

4 Comments

Is the session started? You should have session_start(); at the top of each page: php.net/manual/en/function.session-start.php
And if you echo $selectedDate on the first page right before you fill the session, does it definitely have data in it? (Or echo the session on the first page right after you have assigned it's data)
i used var_dump($selectedDate);die; and the output is "string(6)112012"
What happens if you echo the session variable?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.