Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,903
    Thanks
    15
    Thanked 226 Times in 226 Posts
    Before you get too involved with changes you might want to put this on a php page, upload it and access it.
    PHP Code:
    <?php php_info(); ?>
    And check session_save_path in particular.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  2. #17
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    I have spoken to the host I am now getting this error.

    array(1) { ["logged-in"]=> &bool(true) } Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosoraweb097/b1297/ipg.imperialarchivecom/login2.php:25) in /hermes/bosoraweb097/b1297/ipg.imperialarchivecom/login2.php on line 31

  3. #18
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You have a var_dump($_SESSION) from the looks of it. Simply remove that; any output prior to a header (this includes cookies and sessions as well) will throw an error indicating it cannot modify the headers since the output is already sent.

    Oh yeah, don't forget as well to remove the comments on the location headers.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  4. #19
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    So that's it? Job done?

  5. #20
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by Foster View Post
    So that's it? Job done?
    Test it out. Does it work? If so, then yep. I mean you could probably clean up the $_POST (since that appeared to be one of your errors); you should never read from them unless they are guaranteed to exist using the isset. PHP (either to its great benefit or detriment depending on your view) is very forgiving, much like HTML.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  6. #21
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Quote Originally Posted by DrDOS View Post
    Before you get too involved with changes you might want to put this on a php page, upload it and access it.
    PHP Code:
    <?php php_info(); ?>
    Oh dear.. I just did that:

    Fatal error: Call to undefined function php_info()
    I think you meant phpinfo()
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  7. #22
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    I have one last question, though all seems to be working. If I want to store the username in the session do I just change this

    PHP Code:
    $_SESSION['logged-in'] = true
    to this?

    PHP Code:
    $_SESSION['username'] = true

  8. #23
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,903
    Thanks
    15
    Thanked 226 Times in 226 Posts
    This just means the username element of the array exists and is set.

    $_SESSION['username'] = true;

    To store the username you have to replace true with the actual username.

    $_SESSION['username'] = 'Fred Jones';
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  9. #24
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    How would I set it to the username entered?

    Would this work?
    PHP Code:
    $_SESSION['username'] = '$username'

  10. #25
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,903
    Thanks
    15
    Thanked 226 Times in 226 Posts
    Quote Originally Posted by Foster View Post
    How would I set it to the username entered?

    Would this work?
    PHP Code:
    $_SESSION['username'] = '$username'
    In a word, yes.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  11. #26
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5


    In a word, no.

    DrDos, you're still doing it - giving incorrect advice.

    Those are SINGLE quotes meaning that what will be stored in that session variable LITERALLY what ever is inside them - $username. Not the VALUE of the variable.

    @Foster: Do not use single quotes. Either use double quotes (not much point unless you have other text) or just the variable itself like this:

    PHP Code:
    $_SESSION['username'] = "$username";

    //Or

    $_SESSION['username'] = $username
    Read the link about quotes in my signature if you still can't understand them.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  12. #27
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,903
    Thanks
    15
    Thanked 226 Times in 226 Posts
    Too early in the morning. Should be :

    $_SESSION['username'] = $username;

    just like tango says, or :

    $_SESSION['username'] = 'Fred';
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  13. #28
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Thank you, all working now. Although I'm sure I'll be back.

  14. #29
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Told you I'd be back.

    Is it possible to use my session to display a link only if a user is logged in?

  15. #30
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Yes...

    PHP Code:
    if ((isset($_SESSION['username'])) and ($_SESSION['username'] != ''))
       {
       
    //Create link here
       

    You can treat the $_SESSION array just like any other array and test if certain keys / values exist just like you would in any other if conditional.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


 
Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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