Yeah, its not as easy as copy and pasting a script. First you need a server with php and sql, then you have to connect to your sql database, make the required tables and write the login/signup scripts.
Go here http://www.w3schools.com and learn all the php stuff. When you are done, you can make what you need.
Offline
I have made my own php login with very little help from tutorials. I can Get you started.
Php database
Users | Password | Active | Other stuff for your site like email and account details
Here is my php for loging in on a website.
<?php
session_start();
//Database Information
$dbhost = "localhost";
$dbname = "****";
$dbuser = "****;
$dbpass = "****";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
Print"<head><meta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\"><title>Confirming login</title><link rel=\"icon\" type=\"image/ico\" href=\"/*/database/favicon.ico\"></head>";
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM `users` WHERE `username` LIKE '$username' and `password` LIKE'$password'";
$result = mysql_query($query) or die ( "An error has occured.");
if (mysql_num_rows($result) != 1) {
$error = "Bad Login";
include "login.html";
Print"Username and password combo is incorrect";
} else {
$query = "SELECT * FROM `users` WHERE `username` LIKE '$username' and `password` LIKE'$password' and `active` =1";
$result = mysql_query($query) or die ( "An error has occured.");
if (mysql_num_rows($result) != 1) {
$error = "Username not activated";
Print"You have not activated your account. Please check your email address that you provided for instructions on how to active your account.";
include "login.html";
}else{
$_SESSION['username'] = "$username";
include "memberspage.php";
}
}
mysql_close();
?>The following is for activating the account. confirming email.
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Main</title>
<link rel="icon" type="image/ico" href="/*/database/favicon.ico">
</head>
<?php
if ((isset($_GET["id"]))&&(isset($_GET["string"]))){
$id = $_GET["id"];
$usernames = $_GET["string"];
$username="****";
$password="****";
$database="****";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT * FROM `users` WHERE `username` LIKE '$usernames' AND `userid` LIKE '$id'";
$result = mysql_query($sql) or die ( "An error has occured. Please reload this page to see if the problem is fixed");
$data = mysql_fetch_row($result);
if ($data == ""){
Print"Your account could not be verified. Please verify that the url has not been modified from the e-mail. We were unable to relsove the username. If you are still unsuccessful please contact us.";
}else{
$query = "update `users` set active=1 where userid=$id";
$result = mysql_query($query) or die ( "An error has occured. Please reload this page to see if the problem is fixed");
Print"Congratulations <b> \"$usernames\" </b>. You are now able to login and start creating domain names";
include "login.html";
mysql_close();
}
} else {
die("Extentions not found!");
}
?>Finally Requesting an account
HTML form code
<form action="insert.php" method="post"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> E-mail: <input type="text" name="email"><br> <input type="submit" name="submit" value="Sign me up!" </form>
Php code
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Main</title>
<link rel="icon" type="image/ico" href="/*/database/favicon.ico">
</head>
<?
// check e-mail address
// display success or failure message
if (!preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email']))
{
include 'signup.html';
$email=$_POST['email'];
die("Invalid e-mail address <b>$email</b>. Please check your email address<br>");
} else {
//echo "Valid e-mail address, processing...<br>";
$length=strlen($_POST['password']);
if ($length < 6)
{
include 'signup.html';
echo "Password is not at least 6 characters long<br>";
die(" ");
}else{
//echo "Valid password<br>";
$length=strlen($_POST['username']);
if ($length < 3)
{
include 'signup.html';
echo "Please enter a username with at least three characters.<br>";
die(" ");
}else{
$username="****";
$password="****";
$database="****";
$username1=$_POST['username'];
$password1=$_POST['password'];
$email=$_POST['email'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT * FROM `users` WHERE `username` LIKE '$username1'";
//Print"$sql<br>";
$result = mysql_query($sql) or die ( "Username entered conflicts with something");
$data = mysql_fetch_row($result);
if ($data == ""){
$sql = "SELECT * FROM `users` WHERE `email` LIKE '$email'";
$result = mysql_query($sql) or die ( "email entered conflicts with something");
$data = mysql_fetch_row($result);
//Print"<br>$sql";
if ($data == ""){
$query = "INSERT INTO users VALUES ('','$username1','$password1','$email','0')";
mysql_query($query) or die ( "Query error");
$user_id = mysql_insert_id();
//Print" Your user Id is $user_id";
$validate_link = "http://***/validate.php?id=$user_id&string=$username1";
//Print"Added user. Now checking";
$sql = "SELECT * FROM `users` WHERE `username` LIKE '$username1' AND `password` LIKE '$password1'";
$result = mysql_query($sql) or die ( "Query error can not find user");
//Print"<br>$sql";
include 'signup.html';
Print"<br>The data you entered<br> ";
$data = mysql_fetch_row($result);
Print"Your Id $data[0] .Keep this for reference <br> Your username: $data[1] <br> Your password: $data[2] <br> Your email: $data[3] .We will send you important information about your account here<br><br>";
$headers = "From: ***@***.***.*** \r\n";
$subject = "Confirm account information";
$message = "Welcome to **** To confirm your e-mail address and activate you account please click this link \n\n $validate_link \n\n.If there are any problems with signing up please let us know. \n\n If you did not create an account with us please disregard this message.";
$yoursite = "***";
if(mail("$email", "$subject", "$message", $headers)){
echo "An email has been sent to ".$email.". Please check your e-mail for steps to activate your account. Check your spam folder as sometimes these e-mail can be marked as spam. If you still do not see your e-mail, please <a href='sendemail.php?function=validation&id=$user_id&user=$username1&e=$email'> Click Here</a> to resend.<br>";
}else{
echo "There was an error sending an e-mail to your e-mail address. Please contact us to let us know of the issue.";
}
} else {
include 'signup.html';
Print"Another user has alreadly registered with that email address. If this is you and you can not access your account, you should request a password reset or contact us straight away if otherwise";
}
} else {
include 'signup.html';
Print"We are very sorry but that username already exists on this server. Please go back and try a new username";
}
mysql_close();
}
}
}Tell me if you want the resend activation email code.
PLEASE GIVE ME CREDIT OR DON'T USE.
Last edited by what-the (2011-06-13 02:27:34)
My site Offline
what-the wrote:
I have made my own php login with very little help from tutorials. I can Get you started.
Php database
Users | Password | Active | Other stuff for your site like email and account details
Here is my php for loging in on a website.Code:
<?php session_start(); //Database Information $dbhost = "localhost"; $dbname = "****"; $dbuser = "****; $dbpass = "****"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); Print"<head><meta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\"><title>Confirming login</title><link rel=\"icon\" type=\"image/ico\" href=\"/*/database/favicon.ico\"></head>"; $username = $_POST['username']; $password = $_POST['password']; $query = "SELECT * FROM `users` WHERE `username` LIKE '$username' and `password` LIKE'$password'"; $result = mysql_query($query) or die ( "An error has occured."); if (mysql_num_rows($result) != 1) { $error = "Bad Login"; include "login.html"; Print"Username and password combo is incorrect"; } else { $query = "SELECT * FROM `users` WHERE `username` LIKE '$username' and `password` LIKE'$password' and `active` =1"; $result = mysql_query($query) or die ( "An error has occured."); if (mysql_num_rows($result) != 1) { $error = "Username not activated"; Print"You have not activated your account. Please check your email address that you provided for instructions on how to active your account."; include "login.html"; }else{ $_SESSION['username'] = "$username"; include "memberspage.php"; } } mysql_close(); ?>The following is for activating the account. confirming email.
Code:
<head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Main</title> <link rel="icon" type="image/ico" href="/*/database/favicon.ico"> </head> <?php if ((isset($_GET["id"]))&&(isset($_GET["string"]))){ $id = $_GET["id"]; $usernames = $_GET["string"]; $username="****"; $password="****"; $database="****"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $sql = "SELECT * FROM `users` WHERE `username` LIKE '$usernames' AND `userid` LIKE '$id'"; $result = mysql_query($sql) or die ( "An error has occured. Please reload this page to see if the problem is fixed"); $data = mysql_fetch_row($result); if ($data == ""){ Print"Your account could not be verified. Please verify that the url has not been modified from the e-mail. We were unable to relsove the username. If you are still unsuccessful please contact us."; }else{ $query = "update `users` set active=1 where userid=$id"; $result = mysql_query($query) or die ( "An error has occured. Please reload this page to see if the problem is fixed"); Print"Congratulations <b> \"$usernames\" </b>. You are now able to login and start creating domain names"; include "login.html"; mysql_close(); } } else { die("Extentions not found!"); } ?>Finally Requesting an account
HTML form codeCode:
<form action="insert.php" method="post"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> E-mail: <input type="text" name="email"><br> <input type="submit" name="submit" value="Sign me up!" </form>Php code
Code:
<head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Main</title> <link rel="icon" type="image/ico" href="/*/database/favicon.ico"> </head> <? // check e-mail address // display success or failure message if (!preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email'])) { include 'signup.html'; $email=$_POST['email']; die("Invalid e-mail address <b>$email</b>. Please check your email address<br>"); } else { //echo "Valid e-mail address, processing...<br>"; $length=strlen($_POST['password']); if ($length < 6) { include 'signup.html'; echo "Password is not at least 6 characters long<br>"; die(" "); }else{ //echo "Valid password<br>"; $length=strlen($_POST['username']); if ($length < 3) { include 'signup.html'; echo "Please enter a username with at least three characters.<br>"; die(" "); }else{ $username="****"; $password="****"; $database="****"; $username1=$_POST['username']; $password1=$_POST['password']; $email=$_POST['email']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $sql = "SELECT * FROM `users` WHERE `username` LIKE '$username1'"; //Print"$sql<br>"; $result = mysql_query($sql) or die ( "Username entered conflicts with something"); $data = mysql_fetch_row($result); if ($data == ""){ $sql = "SELECT * FROM `users` WHERE `email` LIKE '$email'"; $result = mysql_query($sql) or die ( "email entered conflicts with something"); $data = mysql_fetch_row($result); //Print"<br>$sql"; if ($data == ""){ $query = "INSERT INTO users VALUES ('','$username1','$password1','$email','0')"; mysql_query($query) or die ( "Query error"); $user_id = mysql_insert_id(); //Print" Your user Id is $user_id"; $validate_link = "http://***/validate.php?id=$user_id&string=$username1"; //Print"Added user. Now checking"; $sql = "SELECT * FROM `users` WHERE `username` LIKE '$username1' AND `password` LIKE '$password1'"; $result = mysql_query($sql) or die ( "Query error can not find user"); //Print"<br>$sql"; include 'signup.html'; Print"<br>The data you entered<br> "; $data = mysql_fetch_row($result); Print"Your Id $data[0] .Keep this for reference <br> Your username: $data[1] <br> Your password: $data[2] <br> Your email: $data[3] .We will send you important information about your account here<br><br>"; $headers = "From: ***@***.***.*** \r\n"; $subject = "Confirm account information"; $message = "Welcome to **** To confirm your e-mail address and activate you account please click this link \n\n $validate_link \n\n.If there are any problems with signing up please let us know. \n\n If you did not create an account with us please disregard this message."; $yoursite = "***"; if(mail("$email", "$subject", "$message", $headers)){ echo "An email has been sent to ".$email.". Please check your e-mail for steps to activate your account. Check your spam folder as sometimes these e-mail can be marked as spam. If you still do not see your e-mail, please <a href='sendemail.php?function=validation&id=$user_id&user=$username1&e=$email'> Click Here</a> to resend.<br>"; }else{ echo "There was an error sending an e-mail to your e-mail address. Please contact us to let us know of the issue."; } } else { include 'signup.html'; Print"Another user has alreadly registered with that email address. If this is you and you can not access your account, you should request a password reset or contact us straight away if otherwise"; } } else { include 'signup.html'; Print"We are very sorry but that username already exists on this server. Please go back and try a new username"; } mysql_close(); } } }Tell me if you want the resend activation email code.
PLEASE GIVE ME CREDIT OR DON'T USE.
Looks cool, I'll implement it tomorrow. I think you're suited for helping with my mmorpg.
Offline
I made a really complicated php login/registration system that uses a database and cookies. I'll see if I can get some of the most important parts of it out so that it makes more sense.
Offline