SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    From Community Crier

    OK,I'm new to PHP and I've been reading a few tutorials but Aaron Bazell's code has got a couple of things in it I have never seen used before,could some-one explain.

    <?php
    include("funclib.inc"); file://dbConnect function info here
    session_start();

    Firstly "file://dbConnect" ???

    Next

    include("loginhtml.inc");
    exit;

    I have never seen "exit;" used in a tutorial before.

    Thats it for now the rest of my questions worked themselves out when I pasted them in here.

    Many thanks for any explanation.

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha...originator of the code here...

    file: is NOT correct

    I used // as comments for the sake of the article and for whatever reason, file: was added. Sorry. As for exit;....it's part of my code so I added it.

    Any other quetions?

    Thanks for reading.

    Sketch
    Aaron Brazell
    Technosailor



  3. #3
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thankyou for your reply.
    I do understand that exit; was part of your code but would it be possible to give some explanation as I have never seen it used before and I believe it is probably quite important.

    I was very interested in your article as I have been trying to find a good tutorial on sessions and your article was better than and tutorial I had found up to date.

    Regards Kelvyn

  4. #4
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure, I don't mind explaining, but bear with me becaus eI'm not sure what level of expertise your PHP is at.

    loginhtml.inc is a form that basically gives you 2 fields: userid and password and a submit. Everything that is needed for that form is included in loginhtml.inc. I used exit afterwards because, if I did not, the rest of the script would execute and I did not want this. If the user was viewing the contents of loginhtml.inc then they did not have permission to view the rest of the file...so it stops. If they login correctly through submitting the form data to itself then they would not return to the login form thus not exiting the script. Does this make sense?

    Sketch
    Aaron Brazell
    Technosailor



  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exit() stops the script from running. You can use it to print an error message before stopping

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  6. #6
    SitePoint Guru
    Join Date
    Feb 2002
    Location
    NZ
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent reply.
    Thanks very much for taking the time.
    I had a feeling it was along those lines somewhere.

    To clarify:
    Your script stops at the first "exit;"
    After they submit username/password it continues to the next part of your script that either registers the user or unregisters the session and returns loginhtml.

    I apologise for all the questions but I'm just starting to figure out php.

  7. #7
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no problem! That's what we're here for. Check out the PHP forum if you need to work through anything else re:PHP...

    Sketch
    Aaron Brazell
    Technosailor



  8. #8
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hey Sketch, looks like I am going to have to twist your arm to write some more PHP articles eh?

  9. #9
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah yeah yeah....send me some chocolate and I'll consider it

    Sketch
    Aaron Brazell
    Technosailor



  10. #10
    Don't get too close, I bite! Nicky's Avatar
    Join Date
    Jul 1999
    Location
    Lancashire, UK
    Posts
    8,277
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I ain't sharing and that's that!

  11. #11
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I saw it, read it, and really enjoyed it

    Very good look into the mind of someone else, and very valuable, well done matey
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright


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
  •