Re: Form problem

From: Date: Tue, 16 Oct 2001 18:55:31 +0000
Subject: Re: Form problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-71250@lists.php.net to get a copy of this message
> Hello, > > I am having a strange problem with some form code. This is a login form, and > most of the time I just put both the HTML form generation code and the > actual database code in the same file. In the code I just check if the > variable for the form element is empty/set or not. > > This works on my dev server and a few others I've tried it on, but it > doesn't work on the production web server of my client. Both are Apache, and > both use PHP 4.0.6. > > At first I was using "isset" instead of "empty" to test, but they both > produce the same problem. > > Any ideas why this works on one server and not another? > > Thanks in advance for any help. > > Here's the code: > > <? > require_once "./php/cfasttemplate.php"; > require_once "./php/cuser.php"; > > > // Are we submitting the login form? > if (!empty($USERNAME)) { > > $user = new CUser; > > if ($user->login($USERNAME, $PASSWORD) != CUSER_SUCCESS) { > echo phpversion(); > exit(); > } > > // Insert user into the online table (EXPIRE the record after 300 seconds) > $query_insert = "INSERT INTO ONLINE VALUES($ses_userid, UNIX_TIMESTAMP(), > (UNIX_TIMESTAMP()+300))"; > > $database = new CDatabase; > > $database->query($query_insert); > > // Reload page to show login changes > $js = "<script language='javascript'>\n"; > $js .= "window.opener.parent.location.reload(1);\n"; > $js .= "window.close();\n"; > $js .= "</script>"; > echo $js; > > } else { > > // Produce the login form > $tpl = new FastTemplate("./templates/"); > $tpl->define(array("login" => "login.html")); > $tpl->parse("LOGIN", "login"); > $tpl->FastPrint("LOGIN"); > > } > > ?> > Hi, Could you please give details on what the problem is? Does it always return TRUE, or FALSE ? If it always return TRUE, you can print it to see what it is. I experienced almost the same problem one week before, and finaly found that there's a session variable of the same name as the one checked in if(). As for variable checking, sometimes I just use the C style: if( $var ), and this also work perfect. Alex

« previous php.general (#71250) next »