How can i pass a value from one webpage to another without using form,plz explain with example

Recommended Answers

All 3 Replies

window.location='url.php?user=blah&password=blah'

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
echo "<a href='page2.php?var1=1&var2=2&var3=3>"."link </a>";
?>

page2.php

on this page you will retrieve the values using $_GET

<?php 

$var1=$_GET["var1"];
$var2=$_GET["var2"];
$var3=$_GET["var3"];

echo "$var1";
echo "$var2";
echo "$var3";

?>

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

page1

session_start();
$_SESSION['var1']="this is variable1";

page2

session_start();
echo $_SESSION['var1'];

output of page2 will be: this is variable1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.