|
-
Sep 9th, 2005, 01:27 AM
#1
Thread Starter
Addicted Member
undifined index.. :( [RESOLVED]
Notice: Undefined index: tu in D:\PHPWEB\enterPortal.php on line 3
Notice: Undefined index: tp in D:\PHPWEB\enterPortal.php on line 4
dbconnect.php
PHP Code:
<?php
$host = "localhost";
$user = "root";
$password = "admin";
$conn = mysql_connect($host, $user, $password)
or die ("Could Not Connect to DB");
?>
enterPortal.php
PHP Code:
<?php
include("dbconnect.php");
$muser = $_POST['tu'];
$mpass = $_POST['tp'];
$sd = mysql_select_db("ifl-sales", $conn)
or die ("Could Not Select DB");
$tableinsert = "select * from portalGuard where username = $muser and password = $mpass";
$sd = mysql_query($tableinsert, $conn);
if($user=$sd['username'])echo "Access denied!";
?>
index.php
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>IFL-SALES PORTAL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#000000">
<?php include("enterPortal.php");?>
<div align="center"></div>
<div align="center"></div>
<form onSubmit="enterPortal" method="post">
<div align="center">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"><table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th nowrap bgcolor="#0000FF"><div align="center"><font color="#00FF00" size="+1">MEMBER
LOGIN</font></div></th>
</tr>
</table><p></p></td>
</tr>
<tr>
<td width="6%"><div align="right"><font color="#00FF00"></font></div></td>
<td width="27%"><font color="#00FF00"><strong>Username</strong></font></td>
<td width="67%"><input name="tu" type="text" size="32"></td>
</tr>
<tr>
<td><div align="right"><font color="#00FF00"></font></div></td>
<td><font color="#00FF00"><strong>Password</strong></font></td>
<td><input name="tp" type="password" size="32"> <input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
i am sure i named it right.. what could be the problem..??
Last edited by titan7262; Sep 12th, 2005 at 02:14 AM.
Reason: update to resolved
-
Sep 9th, 2005, 04:51 AM
#2
PowerPoster
Re: undifined index.. :(
<?php include("enterPortal.php");?>
Basically what happens is, your displaying your form, but before hand, your asking if it has a username and password have been passed to the page, which of course they haven't (but they will when you submit the form?). Its not an error or a warning, but a notice so you can ignore it, its simply saying that it doesn't exist, but thats ok. You can supress it using error_reporting(E_ALL ^ E_NOTICE) (I think) or simply place an @ in front of it.
Having a quick look at EnterPortal, as it stands, if the user opens index.php, it'll spit out an error (cos you haven't entered a username yet), so I would reorganise EnterPortal.php to be something like.
PHP Code:
if($muser != "") { //User has entered something so its time to check
$sd = mysql_select_db("ifl-sales", $conn) or die ("Could Not Select DB");
$tableinsert = "select * from portalGuard where username = $muser and password = $mpass";
$sd = mysql_query($tableinsert, $conn);
if($user=$sd['username']) {
echo "Access denied!";
} else {
//Connected.
}
}
And another thing, at the moment its technically possible to use SQL Injection to completely mess up your db when you use a query like "select * from portalGuard where username = $muser and password = $mpass" that. You need to escape all inputs to make sure they don't do anything tricky (check out php.net for more info on it)
Cheers.
-
Sep 9th, 2005, 05:34 PM
#3
Re: undifined index.. :(
And in addition, your HTML form is wrong. Remove the onSubmit attribute and add an action attribute that contains the path to where the submit data should be sent, presumably enterPortal.php.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 12th, 2005, 02:13 AM
#4
Thread Starter
Addicted Member
Re: undifined index.. :(
i just changed tu and tp and it worked well.. i think tu and tp is a php function.. or a reserved word.. 
CHEERS!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|