Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

91 users online



$PHP_SELF not working in 4.2.0??

$PHP_SELF not working in 4.2.0??

Currently viewing this thread: 1 (0 members and 1 guests)


Adam

Adam

Status: Offline!

$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

bryan

bryan

Neversidian
Status: Offline!

check it out:

<form method=post action=$PHP_SELF?>

That's messed up. Replace it with:

<form method="post" action="$PHP_SELF">

___________________

Mugging Scotty Good.
www.muggingscotty.com

Trav

Trav

Status: Offline!

that won't fix it. in PHP 4.2.0 you have to use $_SERVER['PHP_SELF'];

edit: also, you seem to exit PHP after the $PHP_SELF variable but then use echo() on the next line. you might want to fix that.

___________________

Learn PHP.

Outburst Online

jdk

jdk

Status: Offline!

Yup.Now you don't have $PHP_SELF to use.

Check release info of PHP 4.2.0

JD

___________________

**** I am without my homepage !!!
______________________________
d.k.jariwala
~ simple thought simple act ~
homepage
dont mail me

moderator PHP and Perl forums @ Devshed.

Rad

Rad

thinking of something witty to put here
Status: Offline!

http://www.tutorialforums.com/showthread.php?s=&threadid=9401

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0132 seconds.