Page 1 of 1

Login passing variable

Posted: Sun May 08, 2005 4:58 pm
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

Posted: Sun May 08, 2005 5:14 pm
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
}

Posted: Sun May 08, 2005 5:26 pm
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 ?

Posted: Sun May 08, 2005 6:25 pm
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.

Posted: Sun May 08, 2005 7:11 pm
by John Cartwright
/off topic

All php is written by hand in dreamweaver.. only html and css is rendered automatically.

Posted: Sun May 08, 2005 9:06 pm
by Skara
oh. in that case, I answered him fully. O.o

Posted: Mon May 09, 2005 1:43 am
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!