PDA

View Full Version : Login Tutorial Help.


sevenstars
03-03-2009, 08:46 AM
Hi Everyone!

Just started getting into learning more about PHP and the video's so far are a great help to me personally because I am a visual learner. I know this question was previously asked, but the person that asked for helped jumped around so much when getting professional help it made it confusing for me to follow along to find the fix.

I am getting...

Notice: Undefined index: userid in C:\wamp\www\website\login.php on line 5

Notice: Undefined index: password in C:\wamp\www\website\login.php on line 6

Notice: Undefined index: submitted in C:\wamp\www\website\login.php on line 7

Notice: Undefined variable: rowAccount in C:\wamp\www\website\login.php on line 17

Here is my code:

<?php
require_once("Connections/connection.php"); // database connection
// Catch Field Data
$userid = $_POST['userid'];
$password = $_POST['password'];
$submitted = $_POST['submitted'];
if ($userid && $password){
/////////////////////////////////////////////////
$query = sprintf("SELECT * FROM users where user_name='$userid' and user_password = '$password'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////////////////////
}
if ($rowAccount){

echo "The record exists you may enter";
}elseif($submitted){

echo "You do not exist in the system, access denied!";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER ['PHP_SELF'];?>">
<table width="268" border="1" align="center">
<tr>
<td width="101">Username :</td>
<td width="151"><label>
<input type="text" name="userid" id="userid" />
</label></td>
</tr>
<tr>
<td>Password :</td>
<td><label>
<input type="text" name="password" id="password" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center"><input name="submitted" type="hidden" id="submitted" value="1" />
<input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>

I believe everything is in order from what was shown in the video's. If i go to input data and hit submit it works just fine and does show the correct results, it just so happens that on the initial viewing of the page, it shows those errors.

Thanks a bunch!

davidj
03-03-2009, 08:51 AM
http://www.dreamweaverclub.com/forum/showthread.php?t=31111

sevenstars
03-03-2009, 09:15 AM
http://www.dreamweaverclub.com/forum/showthread.php?t=31111

Thank you for a speedy reply. php.ini was changed

error_reporting = E_ALL & ~E_NOTICE

Thanks again,
~Seven