help with php login script plz
Posted by: berry05 (---.hsd1.ma.comcast.net)
Date: November 21, 2008 09:06PM

i made a php login and registration form...the registration form works well and adds the usernames and passwords to my mySQL table...but when i click login on the login page it stays on that page...it loads something but then it stays on that page...when its suppose to go to either two pages if it logs in successfully or logs in unsuccessfully.

im using dreamweaver btw
im also using wampserver as a client thing..

Options: ReplyQuote
Re: help with php login script plz
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: November 21, 2008 09:10PM

ul need to post up the code

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: help with php login script plz
Posted by: berry05 (---.hsd1.ma.comcast.net)
Date: November 21, 2008 09:14PM

heres the login .php code...

<?php require_once('Connections/login.php'); ?>
<?php
if (!function_exists("GetSQLValueString"winking smiley) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""winking smiley
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string"winking smiley ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != ""winking smiley ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != ""winking smiley ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != ""winking smiley ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != ""winking smiley ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != ""winking smiley ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?><?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username filed'])) {
$loginUsername=$_POST['username filed'];
$password=$_POST['password field'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "good.html";
$MM_redirectLoginFailed = "bad.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_login, $login);

$LoginRS__query =sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"winking smiley, GetSQLValueString($password, "text"winking smiley);


$LoginRS = mysql_query($LoginRS__query, $login) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//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" "[www.w3.org];
<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="200" border="0">
<tr>
<td height="32">Username:</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp; </td>
<td><label>
<input type="text" name="username filed" id="username filed" />
</label></td>
</tr>
<tr>
<td>Password:</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><label>
<input type="password" name="password field" id="password field" />
</label></td>
</tr>
<tr>
<td height="33">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp; </td>
<td><label>
<input type="submit" name="Login Button" id="Login Button" value="Login" />
</label></td>
</tr>
</table>
</form>
</body>
</html>

Options: ReplyQuote
Re: help with php login script plz
Posted by: stevenmartin99 (---.b-ras1.blp.dublin.eircom.net)
Date: November 21, 2008 09:22PM

if (isset($_POST['username filed'])) {
$loginUsername=$_POST['username filed'];
$password=$_POST['password field'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "good.html";
$MM_redirectLoginFailed = "bad.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_login, $login);


you have username_filed instead of username_field twice

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 11/21/2008 09:22PM by stevenmartin99.

Options: ReplyQuote
Re: help with php login script plz
Posted by: berry05 (---.hsd1.ma.comcast.net)
Date: November 21, 2008 09:28PM

nicee find....but thats not it..i tried it and tried logging in again and stays on that page..and doesn't change pages..it loads though put stays on the page...its weird..

Options: ReplyQuote


Sorry, only registered users may post in this forum.