Login passing variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
barney0o0
Forum Newbie
Posts: 11
Joined: Sun May 08, 2005 4:52 pm

Login passing variable

Post by barney0o0 »

sorry, very new to php...and i cant find specifically what im looking for.

Ive added a server behaviour in dreamweaver for a login form, if login fails ive put login.php?failed=true which refers to

<php echo (isset ($_GET[failed]))?" Whoops please try again":"";?>

if i want a sucess statement, whats the correct method and how would i incorporate the users name ie. "Welcome, X"

Many thanks in advance
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

First, don't use Dreamweaver. Learn how to do it by hand. -_-'

Second, here's a really basic login script:
Btw, use <form method="post"> that way you don't see the variables in the addy. ;)

Code: Select all

if (isset($_POST['user'])) {
  if ($_POST['user'] != 'username' || $_POST['pass'] != 'password') {
    die('Error Logging In');
  }
  else {
    print("Welcome, {$_POST['user']}!");
  }
}
else {
  // print login form
}
barney0o0
Forum Newbie
Posts: 11
Joined: Sun May 08, 2005 4:52 pm

Post by barney0o0 »

Thanks Skara for your quick reponse....however im following this book page by page (and i want to make changes that are out of my depth)...

I understand that Dreamweaver may be a 4 letter word, but in this instance could you make an exception and give me a clue ?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

? I answered. You can view the code in DW. >.>

Let me put it this way: Why waste 30 minutes working with php in DW when you can do the same by hand in 5...?

If you really want to use DW, fine. I suppose it can be nice seeing the end result of things. But at least do the php by hand.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

/off topic

All php is written by hand in dreamweaver.. only html and css is rendered automatically.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

oh. in that case, I answered him fully. O.o
barney0o0
Forum Newbie
Posts: 11
Joined: Sun May 08, 2005 4:52 pm

Post by barney0o0 »

Ok...back to the nonce corner. Could you advise me on the correct script for a uceesful login when im using:

login.php?failed=true

in the server behaviour for a incorrect action...

and how would i incorporate it into

<php echo (isset ($_GET[failed]))?" Whoops please try again":"";?>

.....'with welcome, (UserName)'

Thanks...ill leave you alone after this one!
Post Reply