How to get ID and post the ID

 <input type="hidden" id="QR" name="QR" value = "<?php echo $_GET["id"]; ?>">

Your question is unclear. Please explain what it is you are trying to do.

I’m uploading an image and I’m using this code to upload

echo'<td><a href="payment.php?id='.$row['id'].'">Upload QR Code</a></td>'; 

to direct my user and I want to create hidden field with the

value = <?php echo $_GET["id"]; ?> .

What has a hidden field got to do with uploading an image?

What happens that should not, or does not happen that should? Are you saying that there’s nothing in $_GET['id']? If you are, show us how your page is called. Or does it have the wrong value in it?

I wouldn’t just echo $_GET as that’s going to be throwing errors. Make sure it is not empty otherwise why echo it.

<input type="hidden" id="QR" name="QR" value="<?php if(!empty($_GET['id'])){ echo $_GET['id'];} ?>">

Also if this is a required input for QR upload you could wrap that same condition around your submit button.

<?php
if(!empty($_GET['id'])){
	echo '<input type="submit" value="Submit" class="btnSubmit" />'."\r";
}
?>

For this current issue of passing GET to the form, really I wouldn’t even use GET. I assume you are building a <table> with a list of names and your links. Might I suggest you surround this table with <form> tags with attribute method=“post” <form action="" method="post"> and instead of using a link use a submit button like so.

<td><input type="submit" name="uploadQR['.$row['id'].']" value="Upload QR" class="btnSubmit" /></td>

Then on your small upload form code section, you search for the “input VALUE” within the $_POST[‘name’] array. This will return the KEY for this value, which was ['.$row['id'].'] .

$user_id = array_search("Upload QR",$_POST['uploadQR']);

So all-in-all in this example I’ve wrapped the form in the required condition and populated the hidden input.

if($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['uploadQR'])):
	$user_id = array_search("Upload QR",$_POST['uploadQR']); 
	if(!empty($user_id)):
	echo '<form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload">		
  		<input type="hidden" id="QR" name="QR" value="'.$user_id.'">
        <label>Upload QrCode File:</label><br /> <input name="userImage" type="file" class="inputFile" /> 
		<input type="submit" value="Submit" class="btnSubmit" />
    </form>';
	endif;
endif;

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.