Hi everybody,
problem... passing a variable to a sec. php script but as the code is executed the variable in the sec. script is changed. would like to keep the variable the same no matter what takes place in the sec script.
program1.php
<?
<a href="<?php echo"phpcode.php?cmd1=$info1";?>">
?>
phpcode.php
<?
$variable1 = $cmd1; \\ this part works
\\but as the code cont. the $variable1 gets changed..the above line is the first line in the code.. need to keep this variable constant, how is this done after receiving the variable from the program1.php...
?>
problem passing variables to a sec. php script
Moderator: General Moderators
First of all, ur code there is....yes well, here....program1.php:
Sec. php script:
Code: Select all
<?php
echo "<a href='phpcode.php?cmd1=$info1'>";
?>Code: Select all
<?php
$_GETї'cmd1'];
$variable1 = $cmd1;
?>- gite_ashish
- Forum Contributor
- Posts: 118
- Joined: Sat Aug 31, 2002 11:38 am
- Location: India
Re: problem passing variables to a sec. php script
Hi,
If don't want some of your values to change during program execution, you can use define(). See php man for details http://www.php.net/manual/en/language.constants.html
All the best,
If don't want some of your values to change during program execution, you can use define(). See php man for details http://www.php.net/manual/en/language.constants.html
Code: Select all
<?php
// this is sec. php
define( 'var1', $_GETїcmd1] );
echo 'cmd1: ' . $_GETїcmd1] . '<BR>';
echo 'var1: ' . var1 . '<P>';
$_GETїcmd1] .= ' and text2';
// uncommenting following will generate parser error
// var1 .= ' hi !';
echo 'cmd1: ' . $_GETїcmd1] . '<BR>';
echo 'var1: ' . var1 . '<P>';
?>