Checking another file if X variable = on
Moderator: General Moderators
Checking another file if X variable = on
Okay.. I'm very new to PHP but i understand some of it.. I want to know how i would have 1 PHP file with variables on it, and an option to make the variable "X" = "ON" or "OFF" .. I got this page made. Now i want to make another page that if i open will check the other page to see what the variable is, and act upon it. I Dont want to use a 'get' funtion or a button to goto the other page.. I want it to be completly seperate. Please, if this isnt too much trouble, link me to a tutorial that does this or a brief explanation.. Thanks in advance.
I know what you mean. I do it all the time for my online web game and in most sites for db variables.
I have one page called vars.php, it contains most of the variables.
Simply use the require() or include() function to add thoses variables to that page. Then i believe you should be able to easily verify variables on that page.
eg.
I have one page called vars.php, it contains most of the variables.
Simply use the require() or include() function to add thoses variables to that page. Then i believe you should be able to easily verify variables on that page.
eg.
Code: Select all
<?php
// this is vars.php
$pagetitle = "This is my page"; // goes in big letters on main page
$showtitle = "on"; // on or off
?>Code: Select all
<?php
// this is any php page you want to show the title
include("vars.php"); // including the variable page
if ($showtitle == "on"){ // important to use double = sign
echo "<h1>$pagetitle</h1>";
} else {
echo "<br>";
}
?>You could save all the variables to a database. And then vars.php would have to query the database and pull out the variables.
Here is how the table could be setup:
Now create a secure page, possibly by cookies or sessions then create a form that displays the current results of a db, and when updated, will process whatever the contents of the text field is into the db.
Hope it makes enough sence,
/me is pretty sleepy
Here is how the table could be setup:
Code: Select all
$sql = 'CREATE TABLE `test` (
`id` INT(3) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`variable` TINYTEXT NOT NULL,
`value` TINYTEXT NOT NULL
);';Hope it makes enough sence,
/me is pretty sleepy