Current location: Hot Scripts Forums » Programming Languages » PHP » Php Variable


Php Variable

Reply
  #1 (permalink)  
Old 08-14-03, 06:12 AM
phppick phppick is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Php Variable

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>&nbsp;</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">&nbsp;</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---
Reply With Quote
  #2 (permalink)  
Old 08-14-03, 07:06 AM
Stefan's Avatar
Stefan Stefan is offline
Junior Code Guru
 
Join Date: Jun 2003
Location: Utrecht, The Netherlands
Posts: 599
Thanks: 0
Thanked 0 Times in 0 Posts
it would be useful if you mentioned what error you are getting...
Reply With Quote
  #3 (permalink)  
Old 08-14-03, 08:01 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Angry

I got my post deleted ... and I was also asking about the error message !!! why ??!
edit: sorry .. my post wasn't deleted .. I noticed that this post was posted in php section -which means this is SPAM- and I replied there ....

anyway it seems that he copy-pasted the source of the error page .. I think this is the error message ... it's up there ..


Notice: Undefined index: userid in C:\Documents and
Settings\Administrator\Desktop\Test\login.php on line 7

Notice: Undefined index: password in C:\Documents and
Settings\Administrator\Desktop\Test\login.php on line 8

Notice: Undefined index: error in C:\Documents and
Settings\Administrator\Desktop\Test\login.php on line 12


nevertheless, the script still works ... it's just some notices
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 08-14-03 at 08:20 AM.
Reply With Quote
  #4 (permalink)  
Old 08-15-03, 11:07 AM
Jerome Jerome is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: On Earth
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
long big file ...

i will see what i can do about it ...
__________________
Support me by clicking ads
@ http://atomise.blogspot.com
CHEERS
Reply With Quote
  #5 (permalink)  
Old 08-15-03, 08:54 PM
support@deltascripts.com support@deltascripts.com is offline
Newbie Coder
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
userid and those others doesn´t exist on startup. Use isset() to see if they exist before you try to define them, or set them manually.
__________________
-------------------------------
Are Haugsdal
DeltaScripts Developer
<a href="http://deltascripts.com">DeltaScripts.com - PHP Classifieds</a>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 01:22 PM
Custom PHP Scripts BdSBB Job Offers & Assistance 3 12-07-03 09:49 AM
[Tutorial] Hello World Antitrust PHP 10 10-14-03 01:27 PM
PHP MySQL Variable Help tgarske PHP 8 08-25-03 09:01 PM


All times are GMT -5. The time now is 05:23 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.