logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 03-11-2014, 04:32 PM   #1
pspmixer
 
Join Date: Mar 2014
Posts: 7
Default help with php page

im trying to create a login page for website so people who are registered can view my videos
when i testing the page with wampserver it just loops on the login page even though I enter correct details
any able to help me on this please
pspmixer is offline   Reply With Quote
Old 03-12-2014, 01:06 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

then the address is not validating with the db or the redirect is wrong.
without the relevant code no one can help.
Post the part that redirects first.
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 03-12-2014, 11:16 AM   #3
pspmixer
 
Join Date: Mar 2014
Posts: 7
Default

here is all my code for that page
Quote:
<?php require_once('Connections/User_Information.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
$loginUsername=$_POST["username"];
$password=$_POST["password"];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "sports login.php";
$MM_redirectLoginFailed = "denied.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_User_Information, $User_Information);
$LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $User_Information) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Sports Login</title>
<!-- TemplateEndEditable -->
<style type="text/css">
body,td,th {
color: #000;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-color: #0F6;
background-repeat: repeat;
font-family: Arial, Helvetica, sans-serif;
}
.title {
text-align: center;
}
.copyright { font-size: 12px;
}
</style>
</head>
</p>
<img src="images/TECHKAOSbanner.jpg" width="900" height="200" />
<hr/>
<p><a href="file:///C|/Users/HP/Desktop/website/index.html">HOME</a></p>
<p></p>
<html>
<h1>To Access Sports Please Login In</h1>
<form ACTION="<?php echo $_SERVER["PHP_SELF"];
}
?>" METHOD="POST" id"sports_login" name="sports_login">
Username:<br />
<input name"username" type="text" required="required" id="username" form="sports_login" title="username" autocomplete="on" /><br />
Password<br />
<input name"password" type="password" required="required" id="password" title="password" />
<br />
<input type="submit" value="Login" /><br />
</form>
<p><a href="register.php">Register</a>
</p>
</html>
</p>
<p class="copyright">Copyright Techkaos 2014&copy;</p>
pspmixer is offline   Reply With Quote
Old 03-13-2014, 01:20 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

$MM_redirectLoginSuccess = "sports login.php"; thats why it loops to the login page I would think.
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 03-17-2014, 06:00 PM   #5
pspmixer
 
Join Date: Mar 2014
Posts: 7
Default

so how do I fix this then
pspmixer is offline   Reply With Quote
Old 03-18-2014, 01:28 AM   #6
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

direct the successful login to a page that you want
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 03-18-2014, 03:21 AM   #7
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

look, here is a less code flooded login system, it one i put together but havent used any encoding or salting on this version
make a file called login.php. edit the user password data base and table from where the datd will be for log in
Code:
<?php session_start();
$hostname = "localhost";
$username= "test";
$password = "test";
 $database ='test';
try {
    $pdo = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
	 }

$sql= "SELECT * FROM usermanager "; //edit table
$stmt = $pdo->query($sql);
$row =$stmt->fetchObject();
?>
<div  align="center" >
<span style="background-color:#999">

<?php
$ADMIN_USER = $row->username;
$ADMIN_PASSWORD =  $row->password;
if(!$_SESSION['authenticated'])
    if($_POST['loginbutton']) {
        $inputuser = $_POST['input_user'];
        $inputpassword =sha1($_POST['input_password']);		
	echo $inputpassword.'<br>';
	echo $ADMIN_PASSWORD;	
        if(!strcmp($inputuser ,$ADMIN_USER) && !strcmp($inputpassword,$ADMIN_PASSWORD)) {
            $_SESSION['authenticated'] = 1;
           header("Location:index.php");
        }
        else
            displayform(1);
    }
    else
        displayform(0);
function displayform($error) {
    echo "<html><head><title>Please login</title></head><body><style>
	table{ margin-top:100px;}
	td{ font-family: verdana; font-size: 8pt; background-color:#999; input background-color:#fff; }</style>";
    if($error) echo "<p><b>Wrong credentials.</b></p>";
    echo "<form action=\"\" method=\"post\"><table width='300'  border=0  ><tr><td width='100'>username:</td>";
    echo "<td><input type='text' name='input_user'></td></tr><tr><td>password:</td><td><input type='password' name='input_password'></td></tr>";
    echo "<tr><td colspan='2'><input type='Submit' value='Login&raquo;' name='loginbutton'></td></tr></table></form></body></html>";
    exit;
}
?>
</div>
then at the top of any protected page requiring login add this
Code:
<?php @include "login.php"; 
 if(!strcmp($inputuser ,$ADMIN_USER) && !strcmp($inputpassword,$ADMIN_PASSWORD)) {
            $_SESSION['authenticated'] = 1;
            header("Location:".$_SERVER[PHP_SELF]);
        }
?>
if not logged in you will be redirected tpo login and the form
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 03-18-2014, 09:17 PM   #8
pspmixer
 
Join Date: Mar 2014
Posts: 7
Default

sorry I didn't understand that , could I do remote link with you using teamviewer, if so what's best time for you as im in uk
pspmixer is offline   Reply With Quote
Old 03-19-2014, 12:13 AM   #9
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

No but I will put up an example for download later which hopefully will help
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 03-19-2014, 10:00 PM   #10
pspmixer
 
Join Date: Mar 2014
Posts: 7
Default

ok thanks mate
pspmixer is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com