Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Sessions...

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Sessions...

    I am looking for a session tutorial or how to make a session remember the contents of a form input...

    I don't know how to do this but I can easily get some code... Note the information has to stored like this
    1. Form where stuff is put in...
    2. Validation page
    3. Upload *WHERE DATA IS RECALLED*

    I think this can be done by doing this, though I haven't found a tutorial on this...

    Thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Firstly, call session_start() at the top of any page where you intend to use sessions. Secondly, read and write to and from $_SESSION as if it were a normal associative array. Thirdly... oh wait, that's it
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Ok i already had session start, thats ok i didn't say that in my first part, but I really don't know how to do $_SESSION so what would that look like?
    if its like this *but a without the errors*
    Code:
    $_SESSION = "$input";$_SESSION = "$input2";
    I know that is most likely wrong but if its somethign like that I will be able to figure it out...
    But I have no idea how to do this...

    THANKS!

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Hey I tried it but I couldn't get it... how would I put this code in?
    I got three pages... I don't how to do this sorry, and I am really only good at if statements and variables...
    Thanks a lot man...

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    $_SESSION['input1'] = $_POST['input1'];
    Or store everything:
    Code:
    foreach($_POST as $k => $v)
      $_SESSION[$k] = $v;
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    ok i'll try the first one because the second one doesn't make sense, but thats probably cuz I just woke up lol...

  8. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by Twey View Post
    foreach($_POST as $k => $v)
    $_SESSION[$k] = $v;[/code]
    foreach is a loop

    $k = key
    $v = value

    of the array.. I am sure you have seen this type of notation before, you just didnt know what it meant
    Code:
    website.com/index.php?do=login&user=boogyman
    I am sure you would recognize that alot easier if i put it into this type of format
    PHP Code:
    $_GET['do'] = 'login';
    $_GET['user'] = 'boogyman'
    that is using the get method. the post method uses the same principles, but you cannot see the extra characters, you would only see the website.com/search.php

    another way to define an array is
    PHP Code:
    $array("do" =>"login""user"=>"boogyman"); 
    that explicitly defines the key where an array like this
    PHP Code:
    $array("login""boogyman"); 
    would have the defaulted numerical key... so to see the contents of the $array now it would look like this
    PHP Code:
    $array[0] = "login";
    $array[1] = "boogyman"
    as you can see it could potentially create lots of problems by having a numerical keyset rather then a custom one. that is why we use the "name" attribute in our forms, so its alot easier to read and instruct the processing of the page faster and more accurately and efficiently.

  9. #9
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Ok, I sorta got that, but not so much... I put in this:
    Code:
    $_SESSION['input1'] = $_POST['input1'];
    $_SESSION['input2'] = $_POST['input2'];
    $_SESSION['input3'] = $_POST['input3'];
    $_SESSION['input4'] = $_POST['input4'];
    $_SESSION['input5'] = $_POST['input5'];
    $_SESSION['input6'] = $_POST['input6'];
    $_SESSION['input7'] = $_POST['input7'];
    $_SESSION['input8'] = $_POST['input8'];
    $_SESSION['input9'] = $_POST['input9'];
    $_SESSION['input10'] = $_POST['input10'];
    In the validate page (second page)
    What would I put to make so the data from the form is turned back into a variable... like heres an example...
    1. Form page data input into forms
    2. Validation Page data checked
    3. *Problem Area* Write Data from page 1 to specific file...

    I don't know how to do that... that is why I asked for help, I looked in your post boogyman i couldn't find or see anything that said about recalling information, really though most the stuff you said was over my head...

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Why do you name all your inputs input#? That's a really stupid name, it doesn't tell you anything about what the input actually passes. And yes, the loop would be better here.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •