I just want to know how I can pass on a variable with a string in it, from one page to another...
and... how do I redirect from one page to another with php by the way?
I just want to know how I can pass on a variable with a string in it, from one page to another...
and... how do I redirect from one page to another with php by the way?
Try searching for the answers, these questions usually pop up from time to time and have been answered.
Anyway, one way is to use the query string, and access individual variables passed this way by the $GET array.
so
?var1=value
would be accessed as $GET['var1']
for re-direction, one way is to use [man]header/man
Yeah I know.. it's just that I'm ill today heh... I ussually do seach for answers first =)
...but since we have alleady started...
hmm.. so I just put a questionmak in front of the vaiable that I want to pass on to some other page... and then I just use the GET-thing in the page I wanna use that variable right??
the following code will send multiple variables to a new page and redirect to that page automatically:
<code>
header("Location: [url]http://[/url]$myip/catacomb1/enter.php?username=$username&sex=$sex&age=$age&race[0]=$race[0]&str=$str&wis=$wis&dex=$dex&mag=$mag&gp=$gp");
</code>
not the ? for the first var but & for the ones after
<edit>
not = note
</edit>
good luck!!
You could pass variables from page to page in 3 ways that I can think of
Your url would look something like
yourdomain.com/page.php?var1=value
Through Forms (POST method)
You can do this with either hidden form values so they don't know you're doing this, or actually have a form if you're trying to get user-submitted information.
Register Session variables
Basically you register a session, and until you destroy the session, the variable remains accessible throughout multiple pages.
I'm a little rusty on PHP right now...it's been a while, but hopefully these descriptions will help you out.
Cgraz
i dont know if ur problem has been solved but i will try to describe in very simple terms how to send a vaiable from one page to the next...
Demo 1 a simple hyperlink will send the vaiablr $demovar
with the value"hello this is the message"
<!-- page 1 page1.html -->
<a href="http://www.target_url_to.com/pagename.php?domovar=hello this is the message">click here</a>
<!-- end page 1 html -->
<!-- start page 2 pagename.PHP -->
<?php
//take the variable(s) from the url
@extract($_GET);
// print the variable
print $demovar;
?>
<!-- end page 2-->
demo 2
sending the input of a form to the next page and displaying the content on the screen
<!-- page 1 page1.html -->
<form action="http://www.urltosite.com/pagename.php" method="get">
<input type="text" name="name" value="enter name here"><br>
<input type="text name="age" value="enter you age here">
</form>
<!-- end page 1 html -->
<!-- start page 2 pagename.PHP -->
<?php
//take the variable(s) from the url
@extract($_GET);
// print a simple message making use of the variables
print "Welcome $name from you input i know that you are $age years of age";
?>
<!-- end page 2-->
<td> <a href=page2.php?inv_no=<?php echo "$invno"; ?>>Edit</a> </td>
This will send $invno to page 2 where you will use $_GET['inv_no'] to retrieve it from the url.
grumm wrote:the following code will send multiple variables to a new page and redirect to that page automatically:
<code>
header("Location: [url]http://[/url]$myip/catacomb1/enter.php?username=$username&sex=$sex&age=$age&race[0]=$race[0]&str=$str&wis=$wis&dex=$dex&mag=$mag&gp=$gp");
</code>not the ? for the first var but & for the ones after
<edit>
not = note
</edit>good luck!!
Please note that & is not valid XHTML encoding. Use & instead
Leatherback,
if I am not mistaken... within the header() function call to redirect, you must use the ampersand (&) as is, rather than the HTML entity for it (&)
It would be a different story if that value was printed out onto the page. Then, you would be correct.
Talk about digging up a thread from the grave... :p
@: Go, Bears!!