Forums

This topic is locked

User Authorization Form

Posted 16 Oct 2007 16:47:16
1
has voted
16 Oct 2007 16:47:16 Freida Goossen posted:
I have created a user authorization form in Dreamweaver 8 using php 5.0. I will be using it for registration to online courses. The problem is that the form doesn't hyperlink to the address that I have set in the user authorization setup instead it targets itself. So the page called portal.php that is supposed to go to lesson.php instead refers back to itself giving an error message. I know this is probably a very simple fix, but I can't seem to find it. I have looked through the code to see why it is linking back, but cannot find it. I did find that if I put an incorrect password in, it would go to the loginfailed page. Could someone please help? Thank you.

I have included the php code at the beginning and the form code.

<?php require_once('../Connections/school.php'); ?>
<?php
if (!function_exists("GetSQLValueString") {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""
{
$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();
}

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

if (isset($_POST['User'])) {
$loginUsername=$_POST['User'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "Adultstudies";
$MM_redirectLoginSuccess = "lesson.php";
$MM_redirectLoginFailed = "loginfailed.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_school, $school);

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

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

$loginStrGroup = mysql_result($LoginRS,0,'Adultstudies');

//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 );
}
}
?>

form code:

<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="345" border="0" align="center" class="userinterface">
<tr>
<td height="50" colspan="2" valign="middle"><div align="center" class="style14"> Study the Word Login <br />
<br />
</div></td>
</tr>
<tr>
<td width="156"><div align="right">Username:</div></td>
<td width="179"><input name="User" type="text" id="User" tabindex="1" /></td>
</tr>
<tr>
<td><div align="right">Password:</div></td>
<td><input name="password" type="password" id="password" tabindex="2" /></td>
</tr>
<tr>
<td colspan="2"><p align="center" class="style15">
<br />
<input type="submit" name="Submit" value="Log In" tabindex="3" />
</p>
<p align="center" class="style15">Lost your Password? <span class="style17"><a href="findme.php">Go Here</a></span></p>
<p class="style15"><br />
</p></td>
</tr>
</table>
</form>
</td>
</tr>
</table>



Replies

Replied 16 Oct 2007 17:08:39
16 Oct 2007 17:08:39 Freida Goossen replied:
Just to let anyone know that reads my question. I did some more troubleshooting and found that the target page had an error that caused the problem. I am fairly new to the php world.

Reply to this topic