hi

just wandering if anybody can help me.

im trying to create a login to a website with a redirect on login to a user specific page. mainly using dreamweaver cs5

i have set up a connection with a mysql database and recordset and have previously had login working.

i have now tried editing the script to redirect based on the redirect column in the database

however now basic login doesnt seem to be working and i cant get the redirection to work

thanks to anybody who can help me on this,

the script is below!


<?php require_once('../Connections/thinkingwidgets.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;
}
}

mysql_select_db($database_thinkingwidgets, $thinkingwidgets);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $thinkingwidgets) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?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['User Name'])) {
$loginUsername=$_POST['User Name'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "www.thinkingwidgets.com/index.html";
$MM_redirectLoginFailed = "account login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_thinkingwidgets, $thinkingwidgets);

$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, $thinkingwidgets) 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']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
$GLOBALS['MM_UserGroup'] = $loginStrGroup;

$MM_redirectLoginSuccess = mysql_result($LoginRS,0,'redirect');

?>
<!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; cht=UTF-8" />
<title>ThinkingWidgets - Login</title><meta name="Keywords" content="thinkingwidgets, thinking widgets, thinking, widgets, home, education, skills, criticle, tinking, wigets, powerpoint, schools, school, college, collage, smart, smartboard, board, teacher, kirkman, exeter" />
<meta name="Description" content="Thinking Skills for secondary school eduction" />
<meta name="Description" content="description
here"/>

<style type="text/css">
body,td,th {
font-family: "Comic Sans MS", Verdana, Arial, sans-serif;
font-size: 12px;
color: #999;
text-justify: center;
text-align: center;
width: auto;
background-image: none;
height: auto;
background-color: #CCC;
margin-top: 0px;
margin-right: auto;
margin-bottom: auto;
margin-left: auto;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
}
body {
background-color: #CCC;
background-image: none;
background-repeat: no-repeat;
text-align: center;
border-bottom-color: #666;
border: #666, 20px;
overflow: scroll;
visibility: visible;
z-index: auto;
height: auto;
width: auto;
margin: auto;
}
a {
font-family: "Comic Sans MS", Verdana, Arial, sans-serif;
font-size: 12px;
color: #000;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #600;
}
a:hover {
text-decoration: underline;
color: #009;
}
a:active {
text-decoration: none;
color: #600;
border: 30px solid #585A59;
position: absolute;
}
h1,h2,h3,h4,h5,h6 {
font-family: "Comic Sans MS", Verdana, Arial, sans-serif;
}
h1 {
font-size: 24px;
}
h2 {
font-size: 18px;
}
h3 {
font-size: 16px;
}
h4 {
font-size: 14px;
}
h5 {
font-size: 12px;
}
h6 {
font-size: 12px;
font-family: "Comic Sans MS", Verdana, Arial, sans-serif;
text-align: center;
vertical-align: text-bottom;
}

#wrapper {
width: 1000px;
text-align: left;
font-family: "Comic Sans MS", Verdana, Arial, sans-serif;
background-color: #FFF;
background-image: url(../Home/Images/Main%20new.jpg);
height: auto;
position: relative;
background-repeat: no-repeat;
border-right-width: 10px;
border-bottom-width: 10px;
border-left-width: 10px;
border-top-style: none;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #585A59;
border-right-color: #585A59;
border-bottom-color: #585A59;
border-left-color: #585A59;
margin: auto;
border-top-width: 0px;
}
</style>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24163525-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = doent.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == doent.location.protocol ? 'https://ssl' : 'http://www') + '.google-ytics.com/ga.js';
var s = doent.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<div id="wrapper">
<p><a href="home.html"><img src="../Home/Images/Web Logo.jpg" alt="Logo" width="389" height="172" hspace="13" align="left" longdesc="http://www.thinkingwidgets.com/logo.jpg" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
<span id="sprytextfield1">
<label for="User Name">User Name</label>
<input value="<?php echo $row_Recordset1['username']; ?>" name="User Name" type="text" id="User Name" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<p><span id="sprytextfield2">
<label for="Password">Password</label>
<input value="<?php echo $row_Recordset1['password']; ?>" name="Password" type="password" id="Password" />
<span class="textfieldRequiredMsg">A value is required.</span></span></p>
<p>
<input type="submit" name="button" id="button" value="Submit" />
</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<hr />
<tfoot>
</tfoot>
<h6><a href="home.html">Home </a>| <a href="about us.html">About Us</a> | <a href="sample material.html">Sample Material</a> | <a href="purchase.html">Purchase</a> | <a href="account login.html">Account Login</a> | <a href="contact us.html">Contact Us</a>
<p><a href="http://www.thinkingwidgets.com" title="Thinkingwidgets.com" target="_blank">www.thinkingwidgets.com</a> | <a href="mailto:adminthinkingwidgets.com">adminthin kingwidgets.com</a></p>
<p> 2011 Thinking Widgets | All Rights Reserved
</h6>
<tfoot/>
</h1>
</script>
</div>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
</script>
<?php
mysql_free_result($Recordset1);
?>