Re: [PHP] Sending a string with $_POST/$_GET

2005-05-18 Thread Rory Browne
You don't set $_GET variables, like $_GET['name'] = whaever and expect
to do something along the lines of echo $_GET['name'] in another page.

To assign a value as a GET variable on another page, then you make the
url of the other page whatever.php?name=value

Then in whatever.php you can do something like 
?php echo $_GET['name'];   ?

On 5/17/05, Ross [EMAIL PROTECTED] wrote:
 I want to write a string to a variable and use $_POST or $_GET to retrieve
 it on another page.
 
 I keep gettting an undefined index errror. Can someone show me how this is
 done?
 
 Do I have to use session_start() ?
 
 Have checked the documentation, can't find a really basic example.
 
 R.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sending a string with $_POST/$_GET

2005-05-17 Thread Ross
I want to write a string to a variable and use $_POST or $_GET to retrieve 
it on another page.

I keep gettting an undefined index errror. Can someone show me how this is 
done?

Do I have to use session_start() ?

Have checked the documentation, can't find a really basic example.

R. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sending a string with $_POST/$_GET

2005-05-17 Thread Burhan Khalid
Ross wrote:
I want to write a string to a variable and use $_POST or $_GET to retrieve 
it on another page.

I keep gettting an undefined index errror. Can someone show me how this is 
done?

Do I have to use session_start() ?
This would be ideal.
Have checked the documentation, can't find a really basic example.
Well you didn't post any code, so I can't give you specifics, but a 
crude example is :

?php
  session_start();
  $_SESSION['some-string'] = hello I am a string;
  echo 'a href=page2.phpRead the string/a';
?
?php
  session_start();
  echo 'String is : '.$_SESSION['some-string'];
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Sending a string with $_POST/$_GET

2005-05-17 Thread disguised.jedi
 I want to write a string to a variable and use $_POST or $_GET to retrieve
 it on another page.
 
 I keep gettting an undefined index errror. Can someone show me how this is
 done?
/*
How are you trying to accomplish this?  Are you setting the $_GET in
the page code, or using a hidden form?  (If you are using the form,
you can skip this part.  If you aren't, or don't know what I mean,
read on!)  For example:

This code (page1.php):
?php 
$_GET['myvalue'] = 'This is MY GET VALUE';
$_POST['myvalue'] = 'This is MY POST VALUE';
?

With this code (page2.php):
?php
echo $_GET['myvalue'];
echo $_POST['myvalue'];
?
Will not return an error, but the second page won't echo anything. 
However, if you access page2.php with the URL like this:
http://localhost/page2.php?myvalue=This is MY GET VALUE

The first line will output: This is MY GET VALUE

To get the second line to work, you will need to use this:
(page1.php)
form action=page2.php method=post
input type=hidden value=This is MY POST VALUE
input type=submit
/form

When the button is clicked, page2.php, which is the same as before,
will load, and the second line will cause the output of This is MY
POST VALUE.  You can make both lines of page2.php work by
changing the action attribute of the form to page2.php?myvalue=This
is MY GET VALUE.  That way, they will both work.
*/
 Do I have to use session_start() ?
/*
This would be better.  You can use sessions the way I think you are
trying to use $_GET and $_POST.  Just start the session on the first
page, and set an element in $_SESSION and on the next page you can
start the session again and read the value out of the array.  Like
this:

(page1.php)
?php
session_start();
$_SESSION['test'] = 'test value';
?

(page2.php)
?php 
session_start();
echo $_SESSION['test'];
?

The page, page2.php, will show test value if you run page1.php
first.  $_SESSION is probably the easiest of all the superglobals to
use.

Try those, and if I'm completely off-base, and not even helping, try
posting some code, which is ALWAYS a good thing to do.  A big post
asking for help never hurt anyone.  Most people almost never read the
short ones.

Happy coding!!!
*/

-- 
[EMAIL PROTECTED]

PHP rocks!
Knowledge is Power.  Power Corrupts.  Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php