These are my errors and I have no idea why
but not here?
""Notice: Undefined variable: name in c:\program files\apache group\apache\htdocs\secret.php on line 20""
""Notice: Undefined variable: password in c:\program files\apache group\apache\htdocs\secret.php on line 21""
Go away!
Wrong way buddie
This is the code
Page one Seceretdb.php
<h1>Please Log In</h1>
This page is secret.
<form method = post action = "secret.php">
<table border = 1>
<tr>
<th> Username </th>
<td> <input type = text name = name> </td>
</tr>
<tr>
<th>Password</th>
<td> <input type = password name = password> </td>
</tr>
<tr>
<td colspan=2 align = center>
<input type = submit value = "Log In">
</td>
</tr>
</table>
</form>
Page 2
<?
echo "but not here?";
//connect to mysql
$mysql = mysql_connect( 'localhost', 'webauth', 'webauth' );
if(!$mysql){
echo 'cannot connect to database';
exit;
}
//select the appropriote database
$mysql = mysql_select_db( 'Bennybob' );
if (!$mysql){
echo 'cannot select database';
exit;
}
//query the database to see it there is a record which matches
$query = "select count(*) from auth where
name = '$name' and
pass = '$password'";
$result = mysql_query( $query);
if(!$result){
echo 'Cannot run query.';
}
$count = mysql_result( $result, 0, 0);
if ( $count > 0 ){
//visitor's name and password combinations are correct
echo "<h1> you did it Ben</h1>";
}
else{
//vistors name and password combo are incorrect
echo "<h1>Go away!</h1>";
echo "Wrong way buddie";
}
?>