form.html
Code:
...
<form action="processform.php" method="post">
<input type="text" name="Thh">
<!--OR THIS INSTEAD (comment out above <input> and uncomment this to use)
<select name="Thh">
<option value="badboy">Bad Boy</option>
<option value="goodboy">Good Boy</option>
</select>
-->
<!--then submit the form-->
<input type="submit" value="submit">
</form>
...
processform.php
PHP Code:
if(isset($_POST['Thh'])){
$Thh = $_POST['Thh'];
$Thh = addslashes($Thh);
$id = ''; // id of the row you want to update
// IMPORTANT! if you don't specify a row, ALL ROWS will be updated!
$SQL = "UPDATE theme SET Thh = '$Thh' WHERE id ='$id' ";
// This assumes you've already connected to your DB
if(mysql_query($SQL)){ echo 'Success!'; }else{ echo 'Failure.'; }
// if you used the <select> on the form you can easily validate the user's input
// (comment out the lines above and uncomment these):
// $OKvalues = array('badboy','goodboy');
// if(in_array($_POST['Thh'], $OKvalues)){
// $Thh = $_POST['Thh'];
// $id = ''; // id of the row you want to update
// $SQL = "UPDATE theme SET Thh = '$Thh' WHERE id ='$id' ";
// if(mysql_query($SQL)){ echo 'Success!'; }else{ echo 'Failure.'; }
// }
}
Bookmarks