Dragen Posted April 20, 2007 Share Posted April 20, 2007 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 More sharing options...
jitesh Posted April 20, 2007 Share Posted April 20, 2007 <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> Link to comment https://forums.phpfreaks.com/topic/47878-solved-send-post-method-using-a-url/#findComment-233965 Share on other sites More sharing options...
Dragen Posted April 20, 2007 Author Share Posted April 20, 2007 thanks.. I knew I could do it with a form, but was hoping there was another way, withought using forms... Link to comment https://forums.phpfreaks.com/topic/47878-solved-send-post-method-using-a-url/#findComment-233973 Share on other sites More sharing options...
jitesh Posted April 20, 2007 Share Posted April 20, 2007 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']; Link to comment https://forums.phpfreaks.com/topic/47878-solved-send-post-method-using-a-url/#findComment-233974 Share on other sites More sharing options...
Dragen Posted April 20, 2007 Author Share Posted April 20, 2007 thanks! that's brilliant. Link to comment https://forums.phpfreaks.com/topic/47878-solved-send-post-method-using-a-url/#findComment-233978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.