Results 1 to 6 of 6

Thread: noob to php :)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    noob to php :)

    ok, i have basic PHP knowledge and fairly decent mysql, i'm after creating

    a user login area, could someone point me in the right direction, or at least in the direction of a guide

    PINO-

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    It depends on how advanced you want to make it. The way I usually do it is to include a file called which authenticates the user in every php page that I want to protect.

    The easiest way of doing this is using PHP's built in session functions. The reason you need sessions is becuase once the user has logged on you don't want to keep asking them for their details again.

    The authentication file may look something like this:
    PHP Code:
    <?php
    session_start 
    ();

    if (! isset (
    $_SESSION['user_logged_on'])) {
        if (!isset (
    $_POST['submitted'])): ?>
    <p>Enter your user name and password to contuinue:</p>
    <form method="post">
        <input type="text" name="username" />
        <input type="password" name="password" />
        <input type="submit" name="subbmitted" vaelue="Log On" />
    </form>
    <?php 
            
    exit;
        else {
            
    /* check username and password here with mysql*/
            
            /* if they are correct - set the session variable */
            
    $_SESSION['user_logged_on'] = true;
        } 
    }
    ?>
    I don't have time tto write complete code, but itt should give you an idea. The following links may also help you:

    Sessions in PHP
    PHP/MySql Functions
    Using HTTP Forms
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    thanks,

    sessions will not really be need at the moment, i'm trying to learn how to do 2 things

    1) read from database and display on page

    2)if admin enters the 'login area' can edit database

    what it basicly is is so people can look at the progress of there work and how far it has come along!

    thanks

    do you know of the most basic mysql/php guide

  4. #4
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    www.php.net is always a good reference.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    yea its not bad, but i had a REALLy simple guide which just showed you how to edit,add,delete records from the database! dont suppose you've sen one around?

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    I don't know of any online tutorials. I read the manuals mostly. The PHP manual is excellent and the MySql manual isn't too bad either.

    I would recommed the Wrox Beginning PHP books - they give many examples and also go thorugh all the language constructs.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width