PHP Login help? new to PHP

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
onlinegamesnz
Forum Newbie
Posts: 2
Joined: Wed Mar 26, 2008 8:56 pm

PHP Login help? new to PHP

Post 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!!
mikeashfield
Forum Contributor
Posts: 159
Joined: Sat Oct 22, 2011 10:50 am

Re: PHP Login help? new to PHP

Post by mikeashfield »

Code: Select all

<?php
   session_start();
      $_SESSION['USERNAME']=$USERNAME; //Username should be set by your login script.
      echo "Welcome back ".$_SESSION['USERNAME'].".";
?>
shaunak1234
Forum Newbie
Posts: 13
Joined: Thu Nov 03, 2011 12:24 am

Re: PHP Login help? new to PHP

Post by shaunak1234 »

Was the above reply enough, do you want full login script?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP Login help? new to PHP

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply