user2648741
user2648741

Reputation:

Get href value from Category Selection

I want to get values of clicked links in the final page.

e.g. Computer & Network/Components and parts  -- New York /City

Example.

Page1

$Category = $_POST["cat"];
$Subcategory =$_POST["Subcat"]

Page 2

$Province = $_POST["Province"];
$City =$_POST["City"]

{echo "You selected to post on"$Category . "Subcategory" In $Province . $City}

I want to use links not submit button to display selected links

Upvotes: 1

Views: 125

Answers (3)

Jithesh
Jithesh

Reputation: 972

The easiest way would be to use COOKIES. But I recommend using the get method to pass them via url, and that is described in the other answers here.

Example

Page1

$Category = $_POST["cat"];
$Subcategory =$_POST["Subcat"];
$_COOKIE["cat"] = $Category;
$_COOKIE["Subcat"] = $Subcategory;

Page 2

$Category = $_COOKIE["cat"];
$Subcategory =$_COOKIE["Subcat"];
$Province = $_POST["Province"];
$City =$_POST["City"];
echo "You selected to post on".$Category . "Subcategory In". $Province . $City;

Upvotes: 0

Mohammad Masoudian
Mohammad Masoudian

Reputation: 3501

USE $_GET

for example :

<a href="page.php?cat=Category&subcat=Subcategory&province=Province&city=City">link</a>

PHP:

echo "You selected to post on" . $_GET["cat"] . "/" . $_GET["subcat"] . " - " . $_GET["province"] . "/" . $_GET["city"];

Upvotes: 2

Katana314
Katana314

Reputation: 8620

Normally, this sort of thing is accomplished with $_GET variables, rather than $_POST variables. These go after the document name in the URL. Like so:

site.com/myPage.php?cat=Category&subcat=Subcategory

If you absolutely need POST (for reasons I'm not sure I'd understand) you may be able to use a Javascript framework like JQuery to make invisible forms that post when you click a link. Just realize this is going to make navigation hell...each time someone clicks 'Back', the browser will warn them they may be resubmitting information.

Upvotes: 1

Related Questions