HTML Tutorial


 /help/HTML Help Forum   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
PHP Login
Post new topic   Reply to topic    HTML Help Forum -> PHP
View previous topic :: View next topic  
Author Message
curtranhome



Joined: 04 Jun 2008
Posts: 77

PostPosted: Fri Oct 23, 2009 12:31 pm     PHP Login Reply with quote

hey, i got a login script up and running but I want to get it to display an error if the user inputs incorrect data - like right now, if they put in the wrong username/password it would redirect them back to the login page without displaying any errors, the validation page is separate from the actual form, and the form's action attribute sends the data to the validation script. The real question is how do i get the separate page to redirect back to the form and display what needs to be fixed?

Thanks ahead of time,
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4287
Location: MS

PostPosted: Sat Oct 24, 2009 10:37 pm     Reply with quote

Might take a read of this login tutorial.

PHP Login script tutorial

or...

PHP Login System with Admin Features
curtranhome



Joined: 04 Jun 2008
Posts: 77

PostPosted: Tue Oct 27, 2009 12:02 pm     RE: Reply with quote

ok thanks for the links - but I was wondering if there was a way to create a script that doesn't require any database software. I was thinking along the lines of a multiple if... elseif.... else..... statement.

Thank you,
curtranhome
Alston



Joined: 27 Nov 2009
Posts: 3

PostPosted: Fri Nov 27, 2009 4:59 am     Reply with quote

Hello Dear
I have the problem of Login Page in PHP..I want to make login page with PHP coding but i am not aware of this thing so please forward coding here..
Thanks.
curtranhome



Joined: 04 Jun 2008
Posts: 77

PostPosted: Fri Nov 27, 2009 9:14 am     RE: Reply with quote

Ok well, the php script is to long to post here so just click on one of the links above and just copy and paste and make a new file when it says so and you'll have a login page up and going
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4287
Location: MS

PostPosted: Fri Nov 27, 2009 9:31 am     Re: RE: Reply with quote

curtranhome wrote:
ok thanks for the links - but I was wondering if there was a way to create a script that doesn't require any database software. I was thinking along the lines of a multiple if... elseif.... else..... statement.

Thank you,
curtranhome
You have to have the database to be secure enough to keep track of the Passwords and Usernames. If you want something simple that is hosted on another server:

Bravenet Password Protect

Otherwise these:

Depending on what you run:

How to: Create an ASP.NET Login Page - http://msdn.microsoft.com/en-us/library/ms178331.aspx
Creating Login Page - http://www.adesdesign.net/php/tutorials/dreamweaver/secure_login.php
Create login page - http://www.interaktonline.com/Documentation/MXCalendar/4243_createlogin.htm
PHP Login System with Admin Features: http://www.evolt.org/node/60384
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4287
Location: MS

PostPosted: Fri Nov 27, 2009 9:32 am     Reply with quote

Alston wrote:
Hello Dear
I have the problem of Login Page in PHP..I want to make login page with PHP coding but i am not aware of this thing so please forward coding here..
Thanks.
See these:

Depending on what you run:

How to: Create an ASP.NET Login Page - http://msdn.microsoft.com/en-us/library/ms178331.aspx
Creating Login Page - http://www.adesdesign.net/php/tutorials/dreamweaver/secure_login.php
Create login page - http://www.interaktonline.com/Documentation/MXCalendar/4243_createlogin.htm
PHP Login System with Admin Features: http://www.evolt.org/node/60384

Website Access Manager - http://www.coffeecup.com/website-access-manager/
curtranhome



Joined: 04 Jun 2008
Posts: 77

PostPosted: Fri Nov 27, 2009 10:59 am     RE: Reply with quote

Ok thanks for the links
PayneLess Designs



Joined: 28 Feb 2007
Posts: 4287
Location: MS

PostPosted: Fri Nov 27, 2009 11:03 am     Reply with quote

You're welcome. Good luck and have a great weekend.
Straystudio



Joined: 14 Apr 2008
Posts: 297
Location: Nord Italy

PostPosted: Sat Nov 28, 2009 12:50 am     basic PHP passworded document. Reply with quote

curtranhome wrote:
... a script that doesn't require any database software.
Alston wrote:
... so please forward coding here..

I have studied the matter yet re-starting from more basic PHP methods I have developed myself; browsing the web when interest into PHP password-ing comes on, it is hard to run into codes other than pretty-long, complex, database-tied, disheartening ones.

Play this on your Server; adjust filename.php in form action="" (in two places) according to the actual name you save the file.

Password is set by defining the $password variable at top code, final user can never detect it by inspecting source code; check it from browser's top-menù View => Page Source.

It works for one page at time so, if more protected pages are linked each others, user will have to re-enter password along their navigation.
Code:

<?php

$password = "hallo";


    if (isset($_POST['enter'])){

        if ($_POST['pass'] == $password){

            echo('<h1>Reserved Content now displaying</h1>');

    } else {

            echo('wrong password entered - access denied<br>
                  <form action="filename.php" method="post">
                   <input name="pass" type="text"><input name="enter" value="enter page" type="submit">
                  </form>');

  };

} else {

        echo('submit your password:<br>
              <form action="filename.php" method="post">
               <input name="pass" type="text"><input name="enter" value="enter page" type="submit">
              </form>');

};

?>

If interest arises with you, I'll be happy to be back with more explanation and better developed patterns.

Basically, here you have to replicate HTML content on three parts:
- the log-in form displaying at first download (there at bottom code);
- the log-in form again, coming on if user enters wrong/none password;
- the actual content of the password-protected page;
I am omitting html head body Tags for clarity.

This last two ones depending on the if (isset($_POST['submitter_name'])) statement.
Even though, PHP is able to collect value from that "pass"-named textbox directly, without such statement. So, this simpler code also works great and may result as better understendable; password is hello2U now, and the "wrong password ntered" case no longer is there:
Code:
<html>
<head><title>simplest php-passworded page</title>
</head>
<body bgcolor="#90C3FF">
<?php

        if ($_POST['pass'] == "hallo2U"){

            echo('<h1>Reserved Content now displaying</h1>');

    } else {

            echo('<div align="center"><br>
                  <form action="filename.php" method="post">
                   Password: <input name="pass" type="text"><input name="enter" value="enter" type="submit">
                  </form>
                  </div>');

  };

?>
</body>
</html>

If you wish password characters to be displaied as asterisks or bullets (it depends on which browser), change input type="text" into input type="password"

More different passwords to serve more users, also are possible!
Changing the if-statement row into something alike:

if ($_POST['pass'] == "hallo2U" || $_POST['pass'] == "wild" || $_POST['pass'] == "34y-99"){

allows to three different passwords. Here, || operator means "or" as in both PHP and JavaScript Languages.
What I would suggest to improve if so, is to convert the $_POST['pass'] into a more handy variable, to write the serie of allowed passwords this way:


Code:
$p = $_POST['pass'];

        if (
               $p == "hallo2U"
            || $p == "wild"
            || $p == "34y-99"
            || $p == "stray*code"
            || $p == "aGuy"
           
           ){
This works out sort of database existing along with the php file(s) there on the server.
curtranhome



Joined: 04 Jun 2008
Posts: 77

PostPosted: Sat Nov 28, 2009 11:12 am     RE: Reply with quote

Ok thank you, your script is most helpful
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial