0

How do i add variables from

$var1=urlencode(''.$var1.''); 

on page one.php
and use the values from the above variables on page two.php

$var1 = $criteria['".$var1."'];
if($var1=='') $var1 = '';

Page two is included in page one and I am trying to use the same variable value.

6
Contributors
5
Replies
8
Views
5 Years
Discussion Span
Last Post by broj1
0

You want to cash those variable with visit scope (if I got your question right) …so why don’t you use session ?

-1

As jkon said, just use a cookie or a session. So lets say this is page1.php:

<?php 

    $var1 = 55;
    setcookie('var1', $var1, time() * 60*60*24*7); //this cookie will expire in one week

?>

then in page2.php, if you want to access $var1 then:

<?php 

    $varFromAnotherPage = $_COOKIE['var1']; //now we will retrive the cookie and its value by using $_COOKIE[];

?>

Edited by godzab: Wrong function

0

Using php variables

How do i add variables from

on page one.php
and use the values from the above variables on page two.php

$var1 = $criteria['".$var1."'];
if($var1=='') $var1 = '';
Page two is included in page one and I am trying to use the same variable value.

Quoted Text Here

Don't use cookies are a slow thing.. you can do better this:
page1.php

$var1=urlencode($var1); 
$var2=urlencode($var2);

page2.php

include('page1.php');
if($var1==''){$var1 = '';}
if($var2==''){$var2 = '';}
0

If page two is included in page one you can use variables from page one in page two straight away. If they are different variables they should have different names.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.