ScottInTexas
05-31-2007, 12:59 PM
I promise not to ask too many more stupid questions. But Im stuck here and need someone to help me find the way.
When the user clicks on "go" the index is reloaded and this code is executed. I'm getting the prompt "calling validate".
The form
<form action="" method="POST">
<table id="loginForm">
<tr class="smallText">
<td>User ID:</td>
<td><input type="input" name="userID" size="15" class="smallText" /></td>
</tr>
<tr class="smallText">
<td>Password:</td>
<td><input type="password" name="password" size="15" class="smallText" /></td>
</tr>
<tr><td><input type="hidden" name="menuaction" value="login" /></td></tr>
<tr><td><input type="submit" name="submit" value="Go"></td></tr>
</table>
</form>
if (isset($_POST['menuaction'])){
switch ($_POST['menuaction']){
case 'login':
{
echo "Calling validate";
if (validateUser($_POST['userID'], md5($_POST['password'])))
{
echo "if passed";
$SESSION['UserName']=$_POST['userID'];
$SESSION['pswd']=md5($_POST['password']);
$SESSION['validated']=True;
}
else
{
$SESSION['validated']=False;
echo "You Screwed up!";
}
break;
}
case 'Register':
{
$SESSION['currentpage']="Register";
$thisPage="Register";
break;
}
default:
$thisPage="Home";
} //end switch
}//end if
The validate function looks like this:
function validateUser($usr, $pwd){
echo "calling openDB";
$db=openDB();
if (!empty($db)){
echo "open successful";
$qry="SELECT * FROM Users WHERE UserName=".$usr." AND ".$pwd."=UserPswd";
if ($result = mysql_query($qry))
{
return True;
}
else
{
echo "open failed"
die ("Error in query: $query. ".mysql_error());
return False;
}
}
}
Note that I also have prompts there. When this runs all I get is a blank screen and the one "Calling Validate" prompt.
The function is in functions.php and the index.php has the include to include the function page. I did have it set to require_once and changed it to include just to make sure I had that right. Is it my function call?
I think it's just a syntax thing. I'm still learning so it could be any stupid oversight. Your input is appreciated.
When the user clicks on "go" the index is reloaded and this code is executed. I'm getting the prompt "calling validate".
The form
<form action="" method="POST">
<table id="loginForm">
<tr class="smallText">
<td>User ID:</td>
<td><input type="input" name="userID" size="15" class="smallText" /></td>
</tr>
<tr class="smallText">
<td>Password:</td>
<td><input type="password" name="password" size="15" class="smallText" /></td>
</tr>
<tr><td><input type="hidden" name="menuaction" value="login" /></td></tr>
<tr><td><input type="submit" name="submit" value="Go"></td></tr>
</table>
</form>
if (isset($_POST['menuaction'])){
switch ($_POST['menuaction']){
case 'login':
{
echo "Calling validate";
if (validateUser($_POST['userID'], md5($_POST['password'])))
{
echo "if passed";
$SESSION['UserName']=$_POST['userID'];
$SESSION['pswd']=md5($_POST['password']);
$SESSION['validated']=True;
}
else
{
$SESSION['validated']=False;
echo "You Screwed up!";
}
break;
}
case 'Register':
{
$SESSION['currentpage']="Register";
$thisPage="Register";
break;
}
default:
$thisPage="Home";
} //end switch
}//end if
The validate function looks like this:
function validateUser($usr, $pwd){
echo "calling openDB";
$db=openDB();
if (!empty($db)){
echo "open successful";
$qry="SELECT * FROM Users WHERE UserName=".$usr." AND ".$pwd."=UserPswd";
if ($result = mysql_query($qry))
{
return True;
}
else
{
echo "open failed"
die ("Error in query: $query. ".mysql_error());
return False;
}
}
}
Note that I also have prompts there. When this runs all I get is a blank screen and the one "Calling Validate" prompt.
The function is in functions.php and the index.php has the include to include the function page. I did have it set to require_once and changed it to include just to make sure I had that right. Is it my function call?
I think it's just a syntax thing. I'm still learning so it could be any stupid oversight. Your input is appreciated.