Code ziet er zo uit:
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$hash = mysql_query("SELECT * FROM enq WHERE hash = '".mysql_real_escape_string($_POST['code'])."'") or die(mysql_error());
if (isset($_POST['code']))
{
$hashcheck = mysql_query("SELECT 1 FROM enq WHERE hash='".mysql_real_escape_string($_POST['code'])."'") or die(mysql_error());
if (mysql_num_rows($hashcheck) > 0){
$code = $_POST['code'];
$insert =
'INSERT INTO
enq
(keur)
VALUES
("1")
WHERE
hash = '.mysql_real_escape_string($code).'
';
mysql_query($insert);
echo '<div class="success">Gelukt!</div>';
}else{
echo '<div class="error">Code bestaad niet</div>';
}
}
else
{
echo '<div class="error">Vul a.u.b. een code in.</div>';
}
}
en
<form action="/ref-goedkeuring" method="post">
<label for="code" id="code">Code</label>
<input type="text" class="textinput input_large" placeholder="Code" value="" name="code">
<input type="submit" class="blue_button_left" value="Bevestig" name="submit">
</form>
Het stukje van $insert klopt niet...
Moet hier Update of Insert into staan? en hoe moet ik de 'where' neerzetten?
Alvast bedankt!
---
Gelukt:
mysql_query("UPDATE enq SET keur = '1' WHERE hash = '".$code."'");