Jump to content

[SOLVED] send POST method using a url...?


Dragen

Recommended Posts

Hi,

I've got a system going where I have links like this:

<a href=\"clicks.php?id=" . $row['down_id'] . "\">download</a>

the id equals the id number of the current row from my database.

Then clicks.php parses the link and changes the header to a file to be downloaded.. using this code:

<?php
$id = $_GET['id'];
$sql = "SELECT * FROM downloads WHERE down_id = '$id'"; // finds the newest 2 items from $dispcategory
if ($result = mysql_query($sql)) {
	if (mysql_num_rows($result)) {
		while ($row = mysql_fetch_assoc($result)) {
			$result = mysql_query("UPDATE downloads SET clicks = clicks + 1 WHERE down_id = '$id'") or die (mysql_error());
			header("location: " . $row['url'] . "");
			exit;
		}
?>

As you can see it gets the id and saves it as the variable $id to use in the sql.

What I want to do is also send another variable with the link, to be read. The problem is I don't want to add it to the url and use &_GET, because anyone can edit this, so post method would be better... problem is I'm not sure I can send a post variable in a link...

 

Any help?

thanks

Link to comment
https://forums.phpfreaks.com/topic/47878-solved-send-post-method-using-a-url/
Share on other sites

<form name="frm" action="clicks.php" method="post">

<input type="hidden" name="id" value="<?php echo $row['down_id'];?>">

<input type="hidden" name="another_id" value="<?php echo $row['another_id'];?>">

<a href="#" onlcick="javascript:this.form.submit();" or onclick="javascript:document.frm.submit();">download</a>

</form>

You can encode the "another value"

 

and

 

decode after post.

 

base64_encode();

base64_decode();

----------------------------------------

Another way to use session

$_SESSION['id'] =$row['down_id'];

$_SESSION['another_id'] =$row['another_id'];

<a href="clicks.php">download</a>

 

 

and fetch at click.php

$id = $_SESSION['id'];

$another_id = $_SESSION['another_id'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.