Hi.
I have two forms with the following names and properties:
1. register.php --- ----- action="register-exec.php" --- method="POST"
2. register-exec.php --- action="register-exec.php" --- method="POST"


After submitting the register.php, I used session in register-exec.php to store the value of the register.php for later use as follow:

session_start();
$_SESSION['bookTitle'] = $_POST['txtBookTitle'];
$_SESSION['bookInfo'] = $_POST['txtBookInfo'];

Then after submitting the register-exec.php, I wanted to use those session variables, as follow:

if( isset($_POST['register-exec']) ){
     echo $bookTitle;
     echo $_SESSION['bookTitle'];
}

None of them work?
what is wrong ???

Recommended Answers

All 6 Replies

I hope you have session_start in all the required pages. If so, you can try to print out the session variables first, to see if it really has the values.
Try print_r($_SESSION); in all the pages and check if the session variables are really storing any values.

I stored the session in the register-exec.php, and in the same page I would like use those session variables, but when I use the echo and print_r, nothing display, I before Posting it is OK, but after that it is working.

Can you post your code ?

k..
I think u hav to use the seesion registrstion in your first page means in register.php .Then you can retrieve those session variables in the page where ever u want..


Thanks.

You have to use this code in register.php
Try this ...

session_start();
$_SESSION['bookTitle'] = $_POST['txtBookTitle'];
$_SESSION['bookInfo'] = $_POST['txtBookInfo'];

Hi.
Thanks for replying. Finally I used the <Input Hidden /> element of the form. and it worked well.

I will use the posted comments too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.