Re: function login

From: Date: Thu, 17 May 2001 14:21:18 +0000
Subject: Re: function login
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53241@lists.php.net to get a copy of this message
Define how index.php "calls" the login.php file. I assume you mean index.php include() login.php, which has include() on config.php? If so, be sure that the path to config.php as included in login.php is right. Use the fully qualified path to ensure it works right. Other than that, as long as the function declaration comes before you make a call to the function (I remember someone saying that if a function is declared in an included file it must do so before calling that function). Then again, it would give you an error if that was the problem.... ...hm, I don't then see what the problem is. I don't believe what you've showed so far is the reason. My bet is that you're getting a message that you aren't logged on because you really aren't logged on. Something is happening so that...AHA! I just think I found the problem. In your function you are using two variables, $pass and $username which are not declared as global in your function. Add this line at the top of your function: global $pass, $username; See if that fixes it. Plutarck ""Greg K"" <gkelly@kalamazoogazette.com> wrote in message news:9e0bfs$fld$1@toye.p.sourceforge.net... > I am creating a function called login, I have a main file called index.php > .. which has my login form , it calls a login.php file, and in that > login.php there is file include statement which calls config.php and that is > where the function lie. This is my function , now if i don't set this as a > function and just put it my login.php it works fine. But when I name the > function in put it in my config.php no matter what I do all ways giving me > the error You have entered an invalid username or password. I dont know if > this has to do with passing of variables.. or what is going on but if > something can please help me I would appreciate it .. > > Thank You > > function login() { > $query="Select uname from members where pass='$pass'and uname='$username'"; > $result=mysql_query($query) or die("You are not authorized to be here."); > $array= @mysql_fetch_array($result); > $uname = $array[0]; > if($uname=="") > { > echo "You have entered an invalid username or password"; > } > else > > { > echo "You are logged in"; > $remote_address = getenv("REMOTE_ADDR"); > echo "Your IP address is $remote_address."; > } > } > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#53241) next »