943,746 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 862
  • PHP RSS
Dec 20th, 2007
0

Retriving value through url

Expand Post »
How can i pass a value from one webpage to another without using form,plz explain with example
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jyshr is offline Offline
2 posts
since Dec 2007
Dec 20th, 2007
0

Re: Retriving value through url

window.location='url.php?user=blah&password=blah'
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Dec 20th, 2007
0

Re: Retriving value through url

You can also try this one.

for example on page1.php you can have a link that when clicked will pass variables to page2,php

page1.php

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo "<a href='page2.php?var1=1&var2=2&var3=3>"."link </a>";
  3. ?>

page2.php

on this page you will retrieve the values using $_GET
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $var1=$_GET["var1"];
  4. $var2=$_GET["var2"];
  5. $var3=$_GET["var3"];
  6.  
  7. echo "$var1";
  8. echo "$var2";
  9. echo "$var3";
  10.  
  11. ?>
Reputation Points: 11
Solved Threads: 2
Light Poster
tirivamwe is offline Offline
36 posts
since Oct 2005
Dec 20th, 2007
0

Re: Retriving value through url

you could use sessions to store variables between pages.For example:

page1
php Syntax (Toggle Plain Text)
  1. session_start();
  2. $_SESSION['var1']="this is variable1";

page2
php Syntax (Toggle Plain Text)
  1. session_start();
  2. echo $_SESSION['var1'];

output of page2 will be:

this is variable1
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php mySQL Problem
Next Thread in PHP Forum Timeline: searching for php script to sort data...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC