By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

variable vs URL

P: n/a
Lc
Hi,

It's probably very easy, but I cannot find my mistake:

page1.php

<?php
echo "<a href=page2.php?vartrans=5342>Clic</a>";
?>

page2.php

<?php
echo "$vartrans";
?>

When I click on the link on page 1, page 2 appears on the screen but with
the following error message:

Notice: Undefined variable: vartrans in c:\program
files\easyphp1-7\www\page2.php on line 2

What's my mistake?

I use php 4.3.3.

Thank you vm in advance for your help

Lc

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lc wrote:
What's my mistake?

I use php 4.3.3.


You're relying on register_globals being on, and they're off.

Use the superglobal array $_GET instead.

<?php // page2.php
echo "{$_GET['vartrans']}";
?>

read all about it at
http://www.php.net/manual/en/security.globals.php
--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #2

P: n/a
Lc schrieb:
Hi,

It's probably very easy, but I cannot find my mistake:

page1.php

<?php
echo "<a href=page2.php?vartrans=5342>Clic</a>";
?>

page2.php

<?php
echo "$vartrans";
?>

When I click on the link on page 1, page 2 appears on the screen but with
the following error message:

Notice: Undefined variable: vartrans in c:\program
files\easyphp1-7\www\page2.php on line 2

What's my mistake?

I use php 4.3.3.

Thank you vm in advance for your help

Lc

Use better

<?phP
echo $_REQUEST["vartrans"];
?>

to have both, GET and POST method covered
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.