Hi I am getting error with PHP variable,here i am giving all files. pls go through it. PLs clear my Problem . TQ
-----error.htm-----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0032)http://localhost/Test/login.php -->
<HTML><HEAD><TITLE>Some Login</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="Microsoft FrontPage 5.0" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0><BR><B>Notice</B>:
Undefined index: userid in <B>C:\Documents and
Settings\Administrator\Desktop\Test\login.php</B> on line
<B>7</B><BR><BR><B>Notice</B>: Undefined index: password in <B>C:\Documents and
Settings\Administrator\Desktop\Test\login.php</B> on line
<B>8</B><BR><BR><B>Notice</B>: Undefined index: error in <B>C:\Documents and
Settings\Administrator\Desktop\Test\login.php</B> on line <B>12</B><BR>
<FORM id=frmLogin name=frmLogin action=login.php method=post>
<TABLE height=400 cellSpacing=1 cellPadding=1 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=left height=17>
<TABLE cellSpacing=0 cellPadding=0 width=393 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top align=left>
<DIV align=center></DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=393 align=center border=0>
<TBODY>
<TR vAlign=top align=left>
<TD width=393></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=393 align=center border=0>
<TBODY>
<TR vAlign=top align=left>
<TD width=393></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=393 align=center border=0>
<TBODY>
<TR vAlign=top align=left>
<TD width=393>
<TABLE cellSpacing=0 cellPadding=0 width=393 align=center
border=0><TBODY>
<TR>
<TD vAlign=top align=left width=358></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=4 cellPadding=0 width=393 border=0>
<TBODY>
<TR>
<TD vAlign=top align=left>
<DIV align=center><FONT
face="Verdana, Arial, Helvetica, sans-serif" size=1><B><FONT
color=#ffffff>Enter your username and password :
</FONT></B></FONT></DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=4 cellPadding=0 width=300 align=center
border=0><TBODY>
<TR align=left>
<TD vAlign=top width=90>
<DIV align=right><FONT
face="Verdana, Arial, Helvetica, sans-serif"
size=2><B>Username :</B></FONT></DIV></TD>
<TD vAlign=top><INPUT class=mystyle3 maxLength=10 size=14
name=userid> </TD></TR>
<TR align=left>
<TD vAlign=top>
<DIV align=right><FONT
face="Verdana, Arial, Helvetica, sans-serif"
size=2><B>Password :</B></FONT></DIV></TD>
<TD vAlign=bottom><INPUT class=mystyle3 type=password
maxLength=10 size=14 name=password> <INPUT type=submit value=" Login " name=submit> </TD></TR>
<TR align=left>
<TD vAlign=top> </TD>
<TD vAlign=top align=middle>
<DIV
align=left></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM><BR><B>Notice</B>:
Undefined index: error in <B>C:\Documents and
Settings\Administrator\Desktop\Test\login.php</B> on line
<B>152</B><BR></BODY></HTML>
-----END error.htm-----
**************PHP FILES***************************************
-------login.php----
<?
include_once ('httpio.inc');
include_once ('db.inc');
$formVars = HttpPrm();
$userid = $formVars["userid"];
$password = $formVars["password"];
session_start();
if ($formVars["error"]=="")
{
if ($userid && $password) // if the user has just tried to log in
{
$result = mysql_query("select user, pwd from login where user='".$userid."'");
if (!$result)
{
logError("Login.php:" . mysql_error());
gotoPage("login.php?error=0");
exit;
}
if (mysql_num_rows($result) > 0)
{
// if they are in the database register the user id
$detail = mysql_fetch_array($result);
if (md5($password) == $detail["pwd"])
{
$__session_id = session_id();
$__session_pw = $password;
$__session_start_time = date("U");
$__session_user = $detail["user"];
$sv_SessionUser = $__session_user;
$__session_start_time = date("U");
mysql_free_result($result);
session_register("__session_id", "__session_pw", "__session_user", "__session_start_time");
session_register("sv_SessionUser","sv_UserType");
if ($__session_user == "Admin")
jScript("top.location = 'redirect.php';");
else
{
session_destroy();
logError("Login.php: Invalid User type");
gotoPage("login.php?error=1");
exit;
}
exit;
}
else
{
session_destroy();
gotoPage("login.php?error=2");
exit;
}
}
else
{
if (isset($userid))
{
logError("Login.php: Failed login :". $userid);
gotoPage("login.php?error=3");
exit;
}
}
}
}
?>
<html>
<head>
<title>Some Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="frmLogin" id="frmLogin" method=post action="login.php">
<table width="100%" border="0" cellspacing="1" cellpadding="1" height="400">
<tr>
<td height="17" align="left" valign="top">
<table width="393" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="left" valign="top">
<div align="center"></div>
</td>
</tr>
</table>
<table width="393" border="0" cellspacing="0" cellpadding="0" align="center">
<tr align="left" valign="top">
<td width="393"></td>
</tr>
</table>
<table width="393" border="0" cellspacing="0" cellpadding="0" align="center">
<tr align="left" valign="top">
<td width="393"></td>
</tr>
</table>
<table width="393" border="0" cellspacing="0" cellpadding="0" align="center">
<tr align="left" valign="top">
<td width="393">
<table width="393" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="left" valign="top" width="358">
</td>
</tr>
</table>
<table width="393" border="0" cellspacing="4" cellpadding="0">
<tr>
<td align="left" valign="top">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#FFFFFF">Enter your username and password : </font></b></font></div>
</td>
</tr>
</table>
<table width="300" border="0" cellspacing="4" cellpadding="0" align="center">
<tr align="left">
<td width="90" valign="top">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Username
:</b></font></div>
</td>
<td valign="top">
<input type="text" name=userid class="mystyle3" size="14" maxlength="10">
</td>
</tr>
<tr align="left">
<td valign="top">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Password
:</b></font></div>
</td>
<td valign="bottom">
<input type=password name=password class="mystyle3" size="14" maxlength="10">
<input type="submit" name="submit" value=" Login ">
</td>
</tr>
<tr align="left">
<td valign="top"> </td>
<td align="center" valign="top">
<div align="left"></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?
if ($formVars["error"]!="")
{
switch ($formVars["error"])
{
case '0':
alert("No Communication with the server. Please try again later.");
break;
case '1':
alert("You Login info is invalid. Please inform your System Admin.");
break;
case '2':
alert("Password is Invalid. Please try again");
break;
case '3':
alert ("User name or password are Invalid . Please Try again.");
break;
}
}
?>
----END login.php---
---db.inc---
<?php
$db="database";
$db_conn = mysql_connect("localhost","root","")
or die("Could not connect to database");
mysql_select_db($db, $db_conn)
or die("Could not select $db database");
?>
--end db.inc---
----httpio.inc--
<?
function HttpPrm( )
{
global $HTTP_GET_VARS,$HTTP_POST_VARS,$HttpPost;
if ( count($HTTP_POST_VARS) ) return ( $HTTP_POST_VARS );
if ( count($HTTP_GET_VARS) ) return ( $HTTP_GET_VARS );
return ( $HTTP_POST_VARS );
}
function HttpVar( $vKey )
{
global $HTTP_GET_VARS,$HTTP_POST_VARS,$HttpPost;
if ( count($HTTP_POST_VARS) ) return ( $HTTP_POST_VARS[$vKey] );
if ( count($HTTP_GET_VARS) ) return ( $HTTP_GET_VARS[$vkey] );
return ( $HTTP_POST_VARS[$vkey] );
}
function CvtAsc2Htm( $sSrc )
{
global $sHtmLst,$sAscLst;
return ( str_replace($sAscLst,$sHtmLst,$sSrc) );
}
function CvtHtm2Asc( $sSrc )
{
global $sHtmLst,$sAscLst;
return ( str_replace($sHtmLst,$sAscLst,$sSrc) );
}
?>
--end httpio.inc---
PHP VARIABLE -- URGENT PLS
Moderator: General Moderators
I don't think your form variables are getting passed properly.
wht not put this at the top of your login.php page to read the POST varaibles
I think the error your having is in the httpio.inc file.
Try the above, should work!
Mark
wht not put this at the top of your login.php page to read the POST varaibles
Code: Select all
$userid = $HTTP_POST_VARSї"userid"];
$password = $HTTP_POST_VARSї"password"];
$error = $HTTP_POST_VARSї"error"];Try the above, should work!
Mark