Page 1 of 1

moving variables from page to page on A href click

Posted: Wed Sep 28, 2011 1:14 pm
by wizzuriz
Hello all,

I like to hear if there is any one that can help me fix this problem.

I like to pass some $variables from one page to a other page, now I did it with $_Get['$varible'] but I can only get one $variable then and I really like for the user not to see it, this is my a href.
echo "<td id=\"ex1\">" . ""?><a href="javascript:void(0);" onclick="PopupCenter('complete_step.php?<?php echo "step=" . $step_display_text1  ?>', 'myPop1',240,200);"><?php echo $e_r[$step1][$test_id]; ?></a><?php "</td>";            
Now I do get my $step_display_test1 in the $_GET['$variable'] but I need one more and I need to hide it then, I did think of $_POST but making a form in a a href ? well my skills are not that great yet, if you have a idea to how I can get 2 $variables to the linked page and use them there I really like to hear it..

And if you can hide it to That would be really great.

Best regards
wizzuirz

Re: moving variables from page to page on A href click

Posted: Wed Sep 28, 2011 3:11 pm
by jacek
You just seperate them with &
<a href="page.php?example=thing&test=true">Hmm</a>
or to be more valid, use &
<a href="page.php?example=thing&test=true">Hmm</a>

Re: moving variables from page to page on A href click

Posted: Wed Sep 28, 2011 4:13 pm
by wizzuriz
Thanks Jacek,

I'll try it and get back you to asap..

BTW, there was a another thing I was working on getting the user system in the template system you have a video on but its not going that well.

I'm having problems because the init.inc.php have to $page variables and well tried to rename one but still its hard and well to hard for me if you have any clue on how to getting that working please let me know..

Best regards
Wizzurz

Re: moving variables from page to page on A href click

Posted: Thu Sep 29, 2011 4:36 pm
by wizzuriz
Hello Jacek,

I was thinking about making use of the template system and the user system however I can access the protected page without having a session id, I believe its because my protected.page.inc.php is in the pages folder my problem is how do I get the exceptions array to work with this so users aren't logged in don't have access to the pages that is not in the exceptions array. ?

this is my file right now triad to make the best of it..
<?php

session_start();

if (empty($_GET['page'])){
    header('location: ?page=home');
    die ();
}

$core_path = dirname(__FILE__);


$pages = scandir("{$core_path}/pages");
unset($pages['0'], $pages['1']);

foreach ($pages as &$page){
    $page = substr($page, 0, strpos($page, '.'));
}

if (in_array($_GET['page'], $pages)){
    $include_file = "{$core_path}/pages/{$_GET['page']}.page.inc.php";
}else{
    $include_file = "{$core_path}/pages/home.page.inc.php";
}

$data_host = localhost;
$data_user = root;
$data_pass = ;

mysql_connect($data_host, $data_user, $data_pass);
mysql_select_db('Intesira_level_system_date');    




if (isset($_COOKIE['username'], $_COOKIE['password']) && isset($_SESSION['email']) === false){
    if (vaild_credentials($_COOKIE['email'], $_COOKIE['password'])){
        $_SESSION['email'] = htmlentities($_COOKIE['email']);
        
        setcookie('email', $_COOKIE['email'], time() + 604800);
        setcookie('password', $_COOKIE['password'], time() + 604800);
    }
}

$exceptions = array('index', 'register','home','activation');

if (in_array($page, $exceptions) === false){
    if(isset($_SESSION['email']) === false){
        header('location: ?page=home');
        die();
    }
}



?>

I really hope you can help fix this, and I could upload the code if someone else would like it when its working..

best regards
Wizzuriz

Re: moving variables from page to page on A href click

Posted: Fri Sep 30, 2011 9:39 am
by wizzuriz
Hello all,

If there is someone else trying to make use of the template system and add the user system to it please let me know..

Right now I'm working on getting the two init.inc.php files into one, after working with it for some hours I got this.
<?php

session_start();

// include the home page from start when landing on index.php
if (empty($_GET['page'])){
    header('location: ?page=home');
    die ();
}

$core_path = dirname(__FILE__);
// because of the loop in the new init file I had to set a if(!function_exists('function_name')){
                          function function_name()
}
include ("{$core_path}/inc/user.inc.php");

$data_host = localhost;
$data_user = root;
$data_pass = ;

mysql_connect($data_host, $data_user, $data_pass);
mysql_select_db('Intesira_level_system_date');    

// I made a exception to index to because thats the landing page and it will redirect to home which should be the main page.
$exceptions = array('index', 'login', 'register','home','activation');

$pages = scandir("{$core_path}/pages");
unset($pages['0'], $pages['1']);

foreach ($pages as &$page){
    $page = substr($page, 0, strpos($page, '.'));
}

if (in_array($_GET['page'], $pages)){
    $include_file = "{$core_path}/pages/{$_GET['page']}.page.inc.php";
}else{
    $include_file = "{$core_path}/pages/home.page.inc.php";
}

if (isset($_COOKIE['username'], $_COOKIE['password']) && isset($_SESSION['email']) === false){
    if (vaild_credentials($_COOKIE['email'], $_COOKIE['password'])){
        $_SESSION['email'] = htmlentities($_COOKIE['email']);
        
        setcookie('email', $_COOKIE['email'], time() + 604800);
        setcookie('password', $_COOKIE['password'], time() + 604800);
    }
}
// I'm sure we could make this login check in the validated $_GET statement just don't know how yet. 
if (in_array($_GET['page'], $exceptions) === false){
    if(isset($_SESSION['email']) === false){
        header('location: ?page=home');
        die();
    }
}

?>
I really like to be able to use the template system with the login because it will make my life much easier if I can include the header & footer on the index page and just load the content in the include_file.

And I believe its more pro haha ;)


I should say I get it working with the pages now and the session I just can't log in using the login file I could show it here to but lets start with the init file. ;)

Best regards
Wizzuriz
Please let me know if you have a idea on how to make this work.

Re: moving variables from page to page on A href click

Posted: Fri Sep 30, 2011 5:59 pm
by jacek
Trying to combine two tutorials is always going to be awkward. what you should really do is start from scratch and use the info from the tutorials to create a totally new system that has al the features you need.