Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-06-2007, 05:49 AM   #1 (permalink)
rtcl10
banned
 
Join Date: Aug 2007
Posts: 6
rtcl10 is on a distinguished road
eBay Login Page

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>
rtcl10 is offline   Reply With Quote
Old 09-06-2007, 08:29 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,695
redhead is on a distinguished road
In your login.php page you'd have a setting of your session cookie, which will hold the login accept, and after that you'd have a small delay, followed by a header redirect to "http://".$HTTP_HOST.$REQUEST_URI
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 09-06-2007, 09:56 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,471
sde is on a distinguished road
you could either use sessions, or put the destination in a hidden value of the form.

in PHP, $_SERVER['HTTP_REFERER'] returns the previous page the user came from. this example uses the method of embedding the destination in the form.

login.php
PHP Code:
<?php
// process the login and re-direct if necessary
if ($_POST) {
// login logic goes here

  
if ($successful login) {
    if (
$_POST['destination']) {
      
$destination $_POST['destination'];
    } else {
      
$destination "my_default_page.htm";
    }

    
// this forwards the user to the proper page
    
header("location: ".$destination);
    exit; 
  }
}
?>
<html>
<head>
<title></title>
</head>

<body>
<form action="Login.php" method="post">
<input type="hidden" name="destination" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
  <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>
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Launcher Login Page Salchester PHP 6 08-21-2007 03:21 PM
Confirmatin Page & Email ->CONT'D from HTML Forum JMareel PHP 24 03-08-2007 09:33 AM
When refreshing the page redirecting the user to my desired page?? j.gohel Java 1 03-29-2006 02:18 PM
Checking a flag in Opened ASP.net page Continously ! mechtech MS Technologies ( ASP, VB, C#, .NET ) 1 04-19-2005 12:37 PM


All times are GMT -8. The time now is 03:55 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting