SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Non-Member
    Join Date
    Aug 2007
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    eBay Login Screen

    Hiya Guys,

    How do I create a Login Page like eBay using sessions, where users click a "Sign-In" link, available on any page (e.g. Main.html), resulting in the page relocating to the Login Page (Login.html).

    Upon a user signing in, the Sign-In link page (e.g. Main.html) previously displayed reappears, displaying the users username, along with a "Logout" link.

    Upon the users selecting logout (again available on anyway page), the user is redirected to the previously display page.

    The following code is what I have currently:

    Main.html

    Code:
    <html>
    <head>
    <title></title>
    </head>
    
    <body>
    Sign-In
    </body>
    </html>
    Login.html

    Code:
    <html>
    <head>
    <title></title>
    </head>
    
    <body>
    <form action="Login.php" method="post">
      <label>Username:</label>
      <input name="Username" type="text" id="Username">
      <br>
      <br>
      <label>Password:</label>
      <input name="Password" type="text" id="Password">
      <br>
      <br>
      <input type="submit" name="Submit" value="Submit">
    </form>
    
    </body>
    </html>

  2. #2
    Quake 1 Addict CreedFeed's Avatar
    Join Date
    Feb 2002
    Location
    Milwaukee, WI
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Store the URL of the current page in a PHP session variable, or pass it to the login page via query string (login.html?url=main.html). On the Login page, grab the URL passed to it (via session or query string) and save it as a hidden form field or through another session variable. Once the login form is submitted and you verify the username/password is valid, take the URL from wherever you stored it and redirect back

    Code:
    header("Location: $url");
    -- Steve Caponetto
    Quake 1 Resurrection :: CreedFeed

  3. #3
    Non-Member
    Join Date
    Aug 2007
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How abouts do I go about doing that? , I'm new to PHP let alone Login Screens?
    Firstly, How do I create the PHP code for the form?

    All the code I have managed to put together so far, I sent on previous post.

    Any Help Greatly Appreciated!!! - Keen to find out how it's done .

  4. #4
    Non-Member
    Join Date
    Aug 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    eBay Login Screen

    Hi,

    I'm also keen to find out how to code a login script like eBay, as TicTac questions on the following post.

    http://www.sitepoint.com/forums/show...78&postcount=1

    I'm new to PHP, can anyone help on this matter?

  5. #5
    SitePoint Guru brent5392's Avatar
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TicTac View Post
    How abouts do I go about doing that? , I'm new to PHP let alone Login Screens?
    Firstly, How do I create the PHP code for the form?

    All the code I have managed to put together so far, I sent on previous post.

    Any Help Greatly Appreciated!!! - Keen to find out how it's done .
    Have you any way to store your users yet? Have you setup a database?
    PHP | MySQL | (X)HTML | CSS

  6. #6
    Non-Member
    Join Date
    Aug 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    eBay Login Screen

    Yes, using the following code:

    Create Table/Database:

    Code:
    <?php
    $con = mysql_connect("localhost","Username","Password");
    if (!$con)
    {
      die(mysql_error());
    }
    
    // Create database
    if (mysql_query("CREATE DATABASE WB",$con))
    {
      echo "Database Created!";
    }
    else
    {
      echo mysql_error();
    }
    
    // Create table in WB database
    mysql_select_db("WB", $con);
    $sql = "CREATE TABLE Users 
    (
      ID int not null auto_increment,
      Username text,
      Password text,
      primary key(ID)
    )";
    mysql_query($sql,$con);
    
    mysql_close($con);
    ?>
    Add New User (New.html):

    Code:
    <html>
    <body>
    
    <form action="New.php" method="post">
    <h2>Add User</h2>
    Username: <input type="text" name="Username" />
    Password: <input type="text" name="Password" />
    <input type="submit" />
    </form>
    
    </body>
    </html>
    Add New User (New.php):

    Code:
    <?php
    $con = mysql_connect("localhost","Username","Password");
    if (!$con)
    {
      die(mysql_error());
    }
    
    mysql_select_db("WB", $con);
    
    $sql="INSERT INTO Users (Username, Password)
    VALUES
    ('$_POST[Username]','$_POST[Password]')";
    
    if (!mysql_query($sql,$con))
    {
      die(mysql_error());
    }
    echo $_POST[Username] . "'s Account Created Successfully!";
    
    mysql_close($con)
    ?>
    Now What?

  7. #7
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I gave some code on the duplicate thread.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  8. #8
    Non-Member
    Join Date
    Aug 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CreedFeed,

    How do I add your query string solution (Found Here: http://www.sitepoint.com/forums/show...99&postcount=2), to arkinstall login code (Found Here: http://www.sitepoint.com/forums/show...64&postcount=7)


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
  •