|
Posted by Pete Horm on 12/21/05 04:37
Hi everyone,
I have a question about using this variable. I am new to programming and I
had a book that was a couple of years old regarding php programming. None
of the examples were working correctly, until I discovered that my new
version of PHP 4.4 disabled global variables. I figured out how to make
the following php script work correctly, but I don't know if the way I made
it work is the accepted way of doing things with $_POST. I created new
variables in the php script. If anyone could take a look at the following
html and php script, and let me know if this is the right way of doing it
or if there is a better way, I would greatly appreciate it. Thanks in
advance. pete
<html>
<head>
<title>Mailman Login Window</title>
</head>
<body bgcolor="white">
<TABLE cellspacing=1 cellPadding=1 align=center>
<tr>
<td>
<P align=center>Welcome to the<br> </p.</td>
</tr>
<tr>
<td>
<H2 align=center>Mailing List</H2></td>
</tr>
<tr>
<td>
<p align=center>Web Application</p></td>
</tr></TABLE>
<H4><center>
Please provide the requested information:
</center></h4>
<FORM action=trylogon.php method=post>
<TABLE border=1 align=center cellspacing=2 cellPadding=6>
<tr>
<td>Enter User Name:</td>
<td><INPUT size=15 name=username></td>
</tr>
<tr>
<td>Enter Password:</td>
<td><INPUT type=password size=15 name=password></td>
</tr>
<tr>
<td>
<P align=center><INPUT type=submit value=Login name=submit></p></td>
<td>
<P align=center><INPUT type=reset value=Clear></P></td>
</tr>
</TABLE>
</FORM>
</body>
</html>
<?php
$connection = mysql_connect("localhost","user","password");
$db = "mailman";
mysql_select_db($db,$connection) or die("Could not open $db");
$username = ($_POST['username']);
$password = ($_POST['password']);
$sql = "Select * from users where username = '$username' and password =
'$password'";
$result = mysql_query($sql,$connection) or die("Could not execute sql:
$sql");
$num_rows = mysql_num_rows($result);
if ($num_rows > 0 ) {
header("Location: mailman_main.php");
}else {
header("Location: failedlogon.html");
}
?>
[Back to original message]
|