Forum Moderators: coopster

Message Too Old, No Replies

pass constant value problem

         

lecter

3:50 am on Jun 10, 2009 (gmt 0)

10+ Year Member



define.php
-----------------------
<?php
.......
else if($password=='passwd')
{
define( '_test', 1 );
echo "<meta http-equiv='refresh' content='0;url=/defined.php'>";
}
?>
--------------------------

defined.php
--------------------
<?php
defined('_test') or die('no direct access');
?>
---------------------
I want the page jump to defined.php if the user input correct password.
How can I pass the value of constant "_test" from define.php to defined.php after the jump, without include or require, so I can keep the defined.php from direct vivist.

d40sithui

4:24 pm on Jun 10, 2009 (gmt 0)

10+ Year Member



Hmm I wonder this myself. I don't know if this is possible without using include() or variations of it. The only thing I can think of is converting the constant to a session variable. The redirect will make the user go to defined.php directly anyway, so there's no way you can prevent users from typing in the direct URL if they want to.

On a side note, if you're trying to create a log in script, it is easier and more practical to use variables instead of constants. Constants are usually reserved for website settings, such as languages and other website-wide configurations.

example..


<?
elseif($password=='passwd'){
$_SESSION['userId'] = $uid;
header("location: defined.php");
}
?>