tags:

views:

76

answers:

10

i want to send a variable to xxx.php how i do it???

+6  A: 

GET request would be

xxx.php?variable=something

and accessing $_GET['variable'] in php side would work.

S.Mark
A: 
xxx.php?variablename=variablevalue
Jens
A: 

you can send the variable using $_POST or using $_SESSION to pass value of variable from one file to another

Web Worm
+1  A: 

You can send the variable by using the GET method as:

http://www.example.com/welcome.php?fname=Peter

and access it from script as: $_GET["fname"]

codaddict
+4  A: 
  • Pass it as a command line argument
  • Set it in another PHP file and then include it
  • Put it in the query string then access it from $_GET or $_REQUEST
  • Put it in the POST data then access it from $_POST or $_REQUEST
  • Put it in a cookie then access it from $_COOKIES
  • Put it in a session variable then access it from $_SESSION
David Dorward
$_REQUEST will be deprecated
DaNieL
A: 

use query string in your code.

For example

$a = "myval" ;

< a href="xxx.php?var=$a" >

Get values by usnig $_GET['var'] , This would give you the query string value.

pavun_cool
i alredy have the variable in $_POST['text'] and i want to pass it to xxx.php
nisnis84
store the $_POST['text'] to $a ; pass the $a as query string values.
pavun_cool
A: 

It's best you read up the basic about POST and GET first.

Here's a simple tutorial to get you started: http://www.tizag.com/phpT/postget.php

SteD
+2  A: 

Via the URL
for example
www.yoursite.com/xxx.php**?**myVar1=myValue1&myVar2=myValue2
seperate vars by &

or you can do it using a form , via Get <form method='get'>

Step2: in your PHP document
$_GET['myVar1']
$_GET['myVar2']

Radian
A: 

Via query string or in the header of the page

AntonioCS
A: 

Pass it as query string:

xxx.php?your_var=var_value
Sarfraz