samedi 18 avril 2015

PDO Update using Forms

I am trying to incorporate a button onto a page that will when clicked will run a update statement and execute it, but it does not seem to work. Any ideas on how to fix it?



<?php
$query = $handler->query('SELECT * FROM listings WHERE Accept=0;');
while($r = $query->fetch()) {
echo '<td>', $r['CompID'], '</td>','<td>', $r['Name'], '</td>','<td>',$r['Email'], '</td>','<td>', $r['Phone'], '</td>',
'<td>','<a href="' . $r['Name'] . '.php">Company page</a>', '</td>';
echo '</tr>';
}
echo '</table>';
if(isset($_POST['app'])){
$app =$_POST['app'];
}

if($app = !null){
$sql = "UPDATE listings SET Accept=1 WHERE CompID='.$app.';";
$Appquery = $handler->prepare($sql);
$Appquery->bindParam(':.$app.', $_POST['app'], PDO::PARAM_INT);
$Appquery->execute();
}

?>
<br>
<p>Plese enter the Company ID of the company to approve</p>
<br>
<form action="Admin3.php" method ="POST">
<input type="text" name="app"/>
<input type="submit" value="Approve"/>
</form>

Aucun commentaire:

Enregistrer un commentaire