$PHP_SELF not working in 4.2.0??
I am trying to write a real quick login script, but $PHP_SELF is not working right. Here is my code.
PHP:<?php
function LoginForm(){
global $PHP_SELF;
echo "<center>Login";
echo "<form method=post action=$PHP_SELF?><input type=hidden name=op value=Login>";
echo "<table border=1><tr>";
echo "<td>Enter your user name</td><td><input type=text name=UName></td></tr>";
echo "<tr><td>Enter your password</td><td><input type=password name=UPassword></tr></tr>";
echo "</table><br>";
echo "<input type=submit><input type=reset></form>";
}
function Login() {
global $UName, $UPassword;
$link_id = mysql_connect("localhost", "root", "trigger");
mysql_select_db("Misc");
$sql = "SELECT `Name`,`Pass` FROM `user` WHERE `Name` = '$UName' Limit 1";
$result = mysql_query($sql) or die("Cannot query database!");
$data = mysql_fetch_array($result);
$CP = $data["Pass"];
$CU = $data["Name"];
if($CU == $UName && $CP = $UPassword) {
echo "Logged in successfully!";
} else {
die("You enterd wrong information.");
}
}
$op = '';
switch($op)
{
case "Login":
Login();
break;
default:
LoginForm();
break;
}
?>
?>
If I veiw the source of the output of that page it get:
Code:
<center>Login[b]<form method=post action=>[/b]
;
Notice nothing being set for the action attribute? Also if you look at the php code, where it says $op = '';. If I removed that line, the script gives me a notice saying that $op is not defined when it comes to the line with the switch statment.
I am really confused about what is happening. I am using Apacher 1.3.x with php 4.2.0 and register_globals is off, if that makes any difference?
___________________
Current Project: LivermoreMuscle.com
Sig Hosted by Motorspin
