I have this code which permits me to pass a variable to another page, but the problem is i cannot seem to get that variable using the link. We have tried before, this same method and has worked.. could you please check it?
Thanks..
The link:
$sql="SELECT * FROM pianificazione";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
?>
<a href="lista_attivita.php?&id=<?php echo $row['job_id'] ; ?>"><?php echo $row['job'] ?></a>
<?php echo '</br><br />'; }
?>
The page after the link:
include('menu.php');
$id=$_GET['job_id'];
$sql="SELECT * FROM attivita WHERE job_id='$id'";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
?>
<a href="lista_attivita.php?&id=<?php echo $row['att_id'] ?>"><?php echo $row['attivita_da_promuovere'] ?>-<?php echo $row['attivita_tip_merc'] ?>-<?php echo $row['attivita_da_svolgere'] ?>-<?php echo $row['attivita_tip_personale'] ?></a>
You should be using:
You’re also open to SQL injections… Either parse it as an INT:
… or use prepared statements with PDO (instead of the default mysql functions that you’re using, which are no longer recommended).