0 Users appreciate this thread.
joemckellar20 (2014-08-09 01:30:17)just put $password = md5(password)
but this code don't work with it
2014-08-13 09:04:12
CoolApps (2014-08-09 12:55:08)NEVER use MD5 for passwords.
It post likely doesn't work because of you either missing the semicolon, misplaced or MAYBE YOUR DIDN'T DO '$password' WITHIN THE FUNCTION. :fp:
^ Excuse the anger, it's just that this just seem copied and I can see some lack of understanding. I even found out easily why the MD5 encryption (which is not supposed to be used for passwords) didn't work.
2014-08-09 19:56:50
Newer account: NodePoint
PLMasterSSB (2014-08-09 13:20:10)For the logout page you can set a Timeout or something to redirect you to the user to the index or Welcoming Page for your site. Or you can just use JavaScript to logout and still stay on the same page you were on. Now if your going to use that, you should have an access bar on every page of the site. Like you see the "Boomibar" on ever page of my site.
^ Click
(This Image was created from cooltext.com)
PLMasterSSB (2014-08-12 00:49:50)^^
^ Click
(This Image was created from cooltext.com)
joemckellar20 (2014-08-13 02:06:53)@mega Help me make this code bit litte better
Oh MLP RULE fool
2014-08-13 09:09:58
joemckellar20 (2014-09-10 05:32:01)@mega why is this forum skill open
cuz i know have bad ELA and Spelling
CoolApps (2014-09-12 17:23:07)^ The real question is WHY did YOU create a new thread about this when you could've put all of this in the older one.
Newer account: NodePoint
This topic is closed, so you can not post a comment.
Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)
New registered users today: 7
Newest registered user: ElegantVulpes
Please Don't lock this Forum for any Error Just PM me ill fix it
Make a DataBase make sure you have a the name of The DataBase
ok now login your dataBase then create a table with 3 columns and name it membebrs
Add this to the colums
Colum 1
name: id
Tpye: int
Length/Values: 11
Index: PRIMARY
A_I: Yes
____________________________________________
Colum 2
Name: username
Tpye: varchar
Length/Values: 255
____________________________________________
Comlum 3
Name: password
Tpye: char
Length/Values: 255
_____________________________________
oh you can change the Length/Values What ever you want but the id
We are done with the DataBase Set UP
this is just for DataBase to Connect to you website
So let go to your File Manager, WAMP, or any Other webhoster and Create a file named config.php
here the code you need to put in config.php
___________________________________________________________
<?php
session_start();
$dbhost = "localhost";
$dbname = "DataBase Name";
$dbuser = "root";
$dbpass = "password";
$con = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die("MySQL Error: " . mysql_error());
?>
__________________________________
oh change the DataBase Name to your DataBase Name some with Root, Password, and loaclhost
done with that
ok create a file named login.php
here the code you need
_____________________________________________
<?php
session_start();
require "config.php"; //Connection Script, include in every file!
//Check to see if the user is logged in.
if(isset($_SESSION['username'])){
header("location: members.php"
}
if(isset($_POST['submit']))
{
//Variables from the table
$user = $_POST['user'];
$pass = $_POST['pass'];
//Prevent MySQL Injections
$user = stripslashes($user);
$pass = stripslashes($pass);
$user = mysqli_real_escape_string($con, $user);
$pass = mysqli_real_escape_string($con, $pass);
//Check to see if the user left any space empty!
if($user == "" || $pass == ""
{
echo "Please fill in all the information!";
}
//Check to see if the username AND password MATCHES the username AND password in the DB
else
{
$query = mysqli_query($con,"SELECT * FROM members WHERE username = '$user' and password = '$pass'"
$count = mysqli_num_rows($query);
if($count == 1){
//YES WE FOUND A MATCH!
$_SESSION['username'] = $user; //Create a session for the user!
header ("location: members.php"
}
else{
echo "Username and Password DO NOT MATCH! TRY AGAIN!";
}
}
}
?>
<html>
<form name="register" method="post" action="login.php">
Username:
<br/>
<input name="user" type="text" id="user">
Password:
<br/>
<input name="pass" type="password" id="pass"></td>
<br/>
<input type="submit" name="submit" value="Login"></td>
</form>
</html>
________________________________________
it look like this
we are done with that
Make a file signup.php
here the code
______________________________
<?php
session_start(); //Must Start a session.
require "config.php"; //Connection Script, include in every file!
//Check to see if the user is logged in.
//'isset' check to see if a variables has been 'set'
if(isset($_SESSION['username'])){
header("location: members.php"
}
//Check to see if the user click the button
if(isset($_POST['submit']))
{
//Variables from the table
$user = $_POST['user'];
$pass = $_POST['pass'];
$rpass = $_POST['rpass'];
//Prevent MySQL Injections
$user = stripslashes($user);
$pass = stripslashes($pass);
$rpass = stripslashes($rpass);
$user = mysqli_real_escape_string($con, $user);
$pass = mysqli_real_escape_string($con, $pass);
$rpass = mysqli_real_escape_string($con, $rpass);
//Check to see if the user left any space empty!
if($user == "" || $pass == "" || $rpass == ""
{
echo "Please fill in all the information!";
}
else
{
//Check too see if the user's Passwords Matches!
if($pass != $rpass)
{
echo "Passwords do not match! Try Again";
}
//CHECK TO SEE IF THE USERNAME IS TAKEN, IF NOT THEN ADD USERNAME AND PASSWORD INTO THE DB
else
{
//Query the DB
$query = mysqli_query($con,"SELECT * FROM members WHERE username = '$user'"
//Count the number of rows. If a row exist, then the username exist!
$row = mysqli_num_rows($query);
if($row == 1)
{
echo "Sorry, but the username is already taken! Try again.";
}
//ADD THE USERNAME TO THE DB
else
{
$add = mysqli_query($con,"INSERT INTO members (id, username, password) VALUES (null, '$user' , '$pass'
echo "Successful! <a href='members.php'> Click Here </a> to log In.";
}
}
}
}
?>
<html>
<form name="register" method="post" action="signup.php">
Username:
<br/>
<input name="user" type="text" id="user">
<br/>
Password:
<br/>
<input name="pass" type="password" id="pass">
<br/>
Repeat Password:
<br/>
<input name="rpass" type="password" id="rpass">
<br/>
<input type="submit" name="submit" value="Register">
</form>
</html>
______________________
This how is look like
this will be the Members page where all users can do the all fun thing you add so make a file named members.php
here the code
________________________________
<?php
//IF THE USER IS LOGGED IN THEN TELL THE USER, ELSE TELL THE USER TO LOG IN!
session_start();
require "config.php";
//Check to see if the user is logged in.
if(isset($_SESSION['username'])){
echo "Hello ".$_SESSION['username'].",
<br /><a href='logout.php'>Logout</a>";
}
else{
echo "Please <a href='login.php'>Log In </a> to view the content on this page!";
}
?>
_____________________________
here what it look like
Make a fie named logout.php
here the code
_________________________________
<?php
session_start();
require "config.php";
session_destroy();
echo "You have successfully logged out. <a href='login.php'> Click here </a> to login!";
?>
__________________________
here what it look like
2014-08-09 08:40:40