Log in

View Full Version : PHP Form Submission



ccooperxxvii
01-27-2008, 03:43 PM
I've got a validation page in place on all administrative pages of a site and is running perfectly. I'm trying to duplicate it for a different site and server location.

Now I've duplicated the database structure and pulled over the code from the working site and now I've hit a problem that's got me stumped.

When I go to validate the authorized users of the site my submission form doesn't do anything. I don't get the expected error message or a successful message to view the pages.

Any help is greatly appreciated. Here's the code for the validation page that just won't submit.

Thanks.


<?php
session_start();
session_register("sess_var");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Admin Login</title>

</head>
<body bgcolor="#003399">

<?
// includes
include("conf.php");
include("functions.php");
?>

<?php
if (!$HTTPS && $REQUEST_METHOD=="POST") {
# Open a connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

$sql = "SELECT id FROM admin_users WHERE name='$name' and password='$password'";

$result = mysql_query($sql)
or die("Couldn't execute query.");

$num = mysql_numrows($result);

if ($num = 1) {
$sess_var = "Authorized User!";
echo "<p align=\"center\"><font color=ffffff>You have been authorized!</font></p>";
echo "<p align=\"center\"><A HREF=\"index.php\"><font color=ffffff>Click here to continue.</font></A></span></p>";
}
else {
echo "<p align=\"center\"><font color=ffffff>You are <b>NOT</b> authorized to use this site or you have entered incorrect information for your username and password!</span></font></p>";
echo "<p align=\"center\"><A HREF=\"validate.php\"><font color=ffffff>Click here to try again.</font></A></p>";
}
}
else {
?>

<form action="validate.php" method="post">
<table align="center" border="0" cellpadding="5" cellspacing="0" class="text">

<tr bgcolor="#CCCCCC">
<td><strong>Username:</strong></td>
<td>
<input type="text" name="name" size="15">
</td>
</tr>
<tr bgcolor="#CCCCCC">
<td><strong>Password:</strong></td>
<td>
<input type="password" name="password" size="15">
</td>
</tr>
<tr bgcolor="#CCCCCC">
<td colspan="2" align="center">
<input type="submit" value="Submit Information">
</td>
</tr>
</table>
</form>
<?php
}
?>

</body>
</html>


Wrapped code in
tags.

Master_script_maker
01-27-2008, 07:10 PM
wrap your code in
tags or [php ] tags (without the spaces). also you may want to show the other included files. try changing this:
[CODE]<?
// includes
include("conf.php");
include("functions.php");
?>
with this:

<?php
// includes
include("conf.php");
include("functions.php");
?>