Page 1 of 1

PHP Login help? new to PHP

Posted: Tue Nov 29, 2011 2:12 am
by onlinegamesnz
Hi, im creating a PHP login script in dreamweaver, using the User Authentication addon,

A quick question, when logging in it has an option for a seperate page for if the login fails, ie, if i fail to login, it will redirect to loginfail.php.

I want it to to display the text "Login Failed" or whatever, on the same page. Maybe using the ?echo function, im new to php.

Also, im trying to get it to display the users username when logged in, ie logged in as "USERNAME" or Welcome "USERNAME"

Thanks for your help!!

Re: PHP Login help? new to PHP

Posted: Tue Nov 29, 2011 3:09 am
by mikeashfield

Code: Select all

<?php
   session_start();
      $_SESSION['USERNAME']=$USERNAME; //Username should be set by your login script.
      echo "Welcome back ".$_SESSION['USERNAME'].".";
?>

Re: PHP Login help? new to PHP

Posted: Tue Nov 29, 2011 6:19 am
by shaunak1234
Was the above reply enough, do you want full login script?

Re: PHP Login help? new to PHP

Posted: Tue Nov 29, 2011 6:46 am
by social_experiment
onlinegamesnz wrote:A quick question, when logging in it has an option for a seperate page for if the login fails, ie, if i fail to login, it will redirect to loginfail.php.

I want it to to display the text "Login Failed" or whatever, on the same page. Maybe using the ?echo function, im new to php.
The easiest way is to call the login form on itself; <form action="" method="POST" > : leave the action attribute in your form blank