0

hello I'm super stuck on this project.I have a form that echo the id of the user like this

<form method="GET" action="../download_form.php"id="<?php echo 
$row["id"]; ?>">
<button class="btn-md" type="submit" >
<input type="button" name="view" value="Download" class="btn-xs" />
</form></td> 

then i have this download_form.php

$stmt = $pdo->prepare("SELECT  * FROM q1 WHERE id=(the id of the form from 
another page)");

I want to select table from db where id = the id of the form from another page Please help.

angelo
  • 13
  • 1
  • 4
  • in download_form.php, its `$_GET['id']` for the variable you want –  Mar 05 '19 at 01:50
  • hi tim, thanks for responding but still i cant get the id of the form. – angelo Mar 05 '19 at 03:09
  • I've tried this $stmt = $pdo->prepare("SELECT * FROM q1 WHERE id= '".$_GET["id"]."'"); but still i cant get the id of the form. – angelo Mar 05 '19 at 03:14
  • In "action" you have a typo - it should be download_form.php?id= (you have ```"``` instead of ```?```). But I don't understand your HTML there, e.g.unlike ``````, `````` with text between them. Input type button won't submit the form. Also NEVER EVER put GET variables into SELECT ([SQL injection](https://en.wikipedia.org/wiki/SQL_injection)), use [bindParam or bindValue](https://stackoverflow.com/a/5077108/1053562) method. You can also try ```var_dump($_GET)``` before the SELECT to see what data are in GET collection and if "id" is among them. – mikiqex Mar 05 '19 at 07:03

0 Answers0