0

Hi, I'm a web development newbie. I was wondering if this was possible:

Say there's a page where you submit a value in a form, and when you click submit it links to another page. Then that page links to a few more pages. Would you be able to retrieve (and print) the value you submitted in the form on the first page from a page that's not directly connected to it? Would using cookies or sessions work? I'm not sure where to start.

3
Contributors
3
Replies
23
Views
3 Years
Discussion Span
Last Post by AndrisP
0

Would using cookies or sessions work? I'm not sure where to start.

Yes of course its very possible and common but not with HTML alone. Based on your description, you are going to need server side scripting (php, asp.net, jsp, etc..).

How you cary the information from page to page depends on you. Yes it can be done with cookies, session variables, and even reading and writing to a database table(s).

There is no right and wrong, just using the best tool for the job. Its hard to say what the appropriate approach is going to be without really knowing all of hte details, but this should get you going...

0

Thank you for responding. How do you use session variables across different pages? If I do this on one page:

$first_name = $_POST['name'];
$_SESSION['first_name'] = $first name;

And this on another:

echo $_SESSION['first_name'];

It says it's undefined.

0
session_start();
    if ( isset($_POST['name']) ){
            $_SESSION['first_name'] = $_POST['name'];
            }

    $first name = ( isset($_SESSION['first_name']) ? $_SESSION['first_name'] : "");

    echo $first name;

Edited by AndrisP

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.