Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Login Script, PHP Help #3 - Need help creating one
Rating 5 V
FirefoxRocks
post Feb 21 2007, 01:00 AM
Post #1


Super Member
Group Icon

Group: [HOSTED]
Posts: 702
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



It turns out that the authentication script that I copied from http://www.php-mysql-tutorial.com/user-aut...on/database.php doesn't work even when it is left unchanged. What a crappy piece of code.

Now I am trying to build by own login script from scratch. I already have a little knowledge on how to do this (connecting, echoing, retrieving) but I need some more examples and/or tips. I know what I need and maybe this could help you out:
Note: Green items are fixed.
  1. No duplicate username in MySQL Database
  2. Authorized users only. I have to authorize each user or else a message comes up that says that they have not been authorized yet.
  3. IP address logging. This means logging the IP address when registered and logging the IP address at last logon.
  4. After logon, it all redirects to one page (if certain group).
  5. If the username is in moderator status, it redirects to the Moderator Page. Otherwise, it redirects to the Member page.
  6. A lost password function.

That's all I need right now. For everyone who helps, I will mention your Trap17/Astahost username into the the credits page of the site when it is completed! smile.gif biggrin.gif
Go to the top of the page
 
+Quote Post
faulty.lee
post Feb 21 2007, 01:54 AM
Post #2


Premium Member
Group Icon

Group: [HOSTED]
Posts: 495
Joined: 5-November 06
Member No.: 17,016



QUOTE(FirefoxRocks @ Feb 21 2007, 09:00 AM) *
It turns out that the authentication script that I copied from http://www.php-mysql-tutorial.com/user-aut...on/database.php doesn't work even when it is left unchanged. What a crappy piece of code.

Now I am trying to build by own login script from scratch. I already have a little knowledge on how to do this (connecting, echoing, retrieving) but I need some more examples and/or tips. I know what I need and maybe this could help you out:
Note: Green items are fixed.
  1. No duplicate username in MySQL Database
  2. Authorized users only. I have to authorize each user or else a message comes up that says that they have not been authorized yet.
  3. IP address logging. This means logging the IP address when registered and logging the IP address at last logon.
  4. After logon, it all redirects to one page (if certain group).
  5. If the username is in moderator status, it redirects to the Moderator Page. Otherwise, it redirects to the Member page.
  6. A lost password function.
That's all I need right now. For everyone who helps, I will mention your Trap17/Astahost username into the the credits page of the site when it is completed! smile.gif biggrin.gif


I'm assuming you're going to use php as your programming language.

I've just posted some tips regarding this here
http://www.astahost.com/authentication-script-t14988.html

As for ip address, you can always get it from the server's variable
$_SERVER['REMOTE_ADDR']
and
$_SERVER['REMOTE_HOST']

Authorization is just keeping a bit or 2 to indicate the user's status and use the login script to decide what to do with different bit. Same goes or moderator.

Lost password is slightly tougher. You'll need to know how to send email, then you have to choose either let the user key in their own password after they click the "recover password" link on their email, or provide them a temporary password so they can change it later.

Just get the hang of it first. We can come to the detail later, step by step, which is easier to cop with.

Good Luck
Go to the top of the page
 
+Quote Post
mastercomputers
post Feb 21 2007, 04:39 AM
Post #3


PESTICIDAL MANIAC
Group Icon

Group: Members
Posts: 626
Joined: 1-September 04
From: Auckland, New Zealand
Member No.: 27



1) Is your script that you are using based similar off this script you provided in the links?

2)Is there anything different from it that you have done apart from what you're asking for and have already fixed?

3)What version of PHP should this cater for or would you like it to be compatible with PHP3 and up?

I might just improve on this script, keeping it similar to how it's structured it's tables for the database, give me a few hours to have something whipped up.

Cheers,

MC
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Feb 22 2007, 12:43 AM
Post #4


Super Member
Group Icon

Group: [HOSTED]
Posts: 702
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



1. It can be based off the one given in the previous topic (Authentication Script), but I am going to whip something up anyways (maybe similar, maybe not smile.gif)

2. No, just something that works.

3. I have this information provided by cPanel in Trap17.
QUOTE
Apache version 1.3.37 (Unix)
MySQL version 5.0.27-standard
PostgreSQL version 7.4.13
PHP version 5.1.6

So I guess compatibility for PHP 5+ is okay.

I already have the registration thing setup okay. I used to have a version that works, but somehow it has malfunctioned (OMG BACKUP!!!) and now I have nothing else to modify upon.
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Feb 24 2007, 04:05 PM
Post #5


Super Member
Group Icon

Group: [HOSTED]
Posts: 702
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



Okay, I have whipped up this code and IT WORKS!!! smile.gif smile.gif biggrin.gif
CODE
<?php
session_start();
$name = $_POST['username'];
$password = $_POST['password'];

$con = mysql_connect("localhost","portal_xkingdom","Yahoo!rocks");
    if(!$con)
        {
        die('Sorry, the XKingdom Center database has encountered an error right now. Please try again later or contact the website administrator. The MySQL error is: ' . mysql_error());
        }
mysql_select_db("portal_xkingdom", $con);

$result = mysql_query("SELECT * FROM users WHERE name='$name' and password = '$password'");
$auth = mysql_query("SELECT auth FROM users");
$rowcheck = mysql_num_rows($result);
if($rowcheck==1)
    {
    /* while($auth_check = mysql_fetch_array($auth))
        {
        if($auth_check==YES)
            { */
            $_SESSION['db_is_logged_in'] = true;
            setcookie("user", "$name", time()+86400);
            header('Location: moderate.php');
            header('(anti-spam-content-type:) text/html;charset=iso-8859-1');
            /* }
        elseif($auth_check==NO)
            {
            $error="You are not authorized as an XKingdom Member yet. Please try again later. If this problem persists for more than 24 hours, please contact the website administrator.";  
            }
        }*/
    }
elseif($rowcheck>1)
{
$error="You have entered an incorrect username/password combination. Please try again. If you forgot your password, contact the website administrator.";
        header('(anti-spam-content-type:) text/html;charset=iso-8859-1');
}
header('(anti-spam-content-type:) text/html;charset=iso-8859-1');
mysql_close();
?>


I have built the code from scratch using the W3Schools help and my previous knowledge from browsing a variety of downloaded PHP scripts which DIDN'T work. I have commented out the authorization part because it isn't working. This means that I have re-met the green requirements wacko.gif Now i just need to meet the other requirements, which number isn't that important. I need some more help with that.

This post has been edited by FirefoxRocks: Feb 26 2007, 11:00 PM
Go to the top of the page
 
+Quote Post
lonelym
post May 18 2007, 07:40 AM
Post #6


Member - Active Contributor
Group Icon

Group: Members
Posts: 91
Joined: 18-May 07
Member No.: 22,008



QUOTE
You don't need to make a login page from scratch. That'd be like ... like... working. o_O.


I suggest going to planetsourcecode.com, search ALS (Advance Login System) and download it. extract it to your htdocs, and open install.php. It has a register/login system, email activation system, secure pages for higher members and admins, a message center, news, and even member hiearchy. If you want to make one from scratch, I suggest reading the php files of the ALS and checking to see how it was made. Good luck.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Make A Text Based Online Game Script ?(23)
  2. PHP: Writing A Generic Login And Register Script(14)
  3. Howto: Change Graphical Login To Text(3)
  4. How To Save A Image In Pdf File And Download It?(10)
  5. Creating A Game In Rpg Maker 2000/2003(18)
  6. 3ds Max Tutorial #2-creating Reflective Materials(1)
  7. Bash Script To Display Your Ip(9)
  8. Help Needed To Create Login Script With Perl/cgi(21)
  9. Need Help With A PHP - MySQL Registration Script(13)
  10. Creating Irc Chat Room...(10)
  11. PHP Tutorial: Form Verification And Simple Validation(12)
  12. Creating Executable Jar Files(9)
  13. Creating New Process Under Alternate Credentials (createprocessasuser)(6)
  14. Running Vba Script In Excel(6)
  15. Creating Flash Image/slideshow(2)
  1. Login System Using A Mysql Db(5)
  2. Best Software For Creating Games(9)
  3. Very Simple Login-script(18)
  4. A Simple Register Script(3)
  5. Auto-click Script(7)
  6. Creating Interactive Pdf Documents(2)
  7. Myspace Gold Script(2)
  8. Looking For Script(5)
  9. Creating A Php Login Script(3)
  10. Myspacetv Download Php Script Help(6)
  11. Automatic Typing Script(3)
  12. [fl]snow Effect(4)
  13. Creating An Mmo(1)


 



- Lo-Fi Version Time is now: 13th October 2008 - 04:24 PM