I've tried everything that I found on this community and other sites. But I'm still failing to complete my objective.
What I want to achieve:
On one page I have a input box with a button. When I fill in de ID number I want to get all the information out of mysql which is linked with this ID number....For some reason it doesn't work. Any tips or hints?
<?php
$servername = "xxxxx";
$username = "xxxxx";
$password = "xxxxx";
$dbname = "xxxxxx";
try{
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT id, voornaam FROM sollicitatie_form WHERE id= "echo ($_POST['zoek'])"";
// $stmt->bindParam(':id', $id, PDO::PARAM_STR);
$stmt->bindParam(':voornaam', $voornaam, PDO::PARAM_STR);
$stmt->exec($sql);
$result = $stmt->fetchAll();
foreach ($result as $row){
echo "{$row['voornaam']}";
}
}
// use exec() because no results are returned
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" /></meta>
<head>
<title>Sollicitatie Formulier</title>
<link href="styletest.css" rel="stylesheet">
</head>
<body>
<div class="form">
<div class="tab-content">
<h1>Sollicitatie Formulier</h1>
<form method="post" enctype="multipart/form-data" >
<div class="top-row">
<div class="field-wrap">
<div class="field-wrap">
<input type="text" name="zoek" value="">
<input type="submit" name="submit" value="zoek">
</div> <!-- /field-wrap-->
</form>
</div><!-- /tab-content-->
</div> <!-- /form -->
</body>
</html>