1
我有我的數據庫中添加字段的按鈕: 我想添加一個按鈕在我的MySQL PHP的網頁上添加一些字段到數據庫中。PHP的網站 - mysql的DB - 函數陣列
<div class ="row">
<!-- blacklist button -->
<div class="col-sm-6">
<h4 class="page-title"><font color="#e34749">Adaugare Blacklist</font></h4>
<div class="card-box">
<?php
$q = $_SESSION['user_id'];
$update_id = $q;
if (isset($_POST["adauga_user_blacklist"])) {dbuserInsertblacklist('blacklist', $form_user_blacklist); }
?>
<form action="" method="post" class="form-horizontal" role="form">
<div class="form-group">
<label class="col-md-2 control-label">Nume client</label>
<div class="col-md-9">
<input type="text" name="numeb" class="form-control" placeholder="Nume client pentru banat">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Telefon</label>
<div class="col-md-9">
<input type="text" name="telefonb" class="form-control" placeholder="Telefon client pentru banat">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Motiv</label>
<div class="col-md-9">
<input type="text" name="motivb" class="form-control" placeholder="Motivul banarii ">
</div>
</div>
<div align="center"><button type="submit" name="adauga_user_blacklist" class="btn btn-danger btn-trans waves-effect w-md waves-info btn-lg m-b-5"><i class="fa fa-plus"></i> <span>Adauga</span> </button></div>
</form>
</div>
</div>
</div>
在功能我:
// Form user blacklist - banat
$nume_blacklist = $_POST['numeb'];
$telefon_blacklist = $_POST['telefonb'];
$motiv_blacklist = $_POST['motivb'];
$form_user_blacklist = array(
'nume_blacklist' => $numeb,
'telefon_blacklist' => $telefonb,
'motiv_blacklist' => $motivb
);
function dbuserInsertblacklist($table_name, $form_user_blacklist) {
// retrieve the keys of the array (column titles)
$fields = array_keys($form_user_blacklist);
$error = "";
if (empty($_POST['numeb']) OR empty($_POST['telefonb']) OR empty($_POST['motivb'])) { echo "<div align='center'> <h4><font color='#f0ad4b'>* Va rugam sa completati toate campurile!</font></h4></div>"; $error=1; }
if ($error !=1) {
// build the query
$sql = "INSERT INTO ".$table_name."
(`".implode('`,`', $fields)."`)
VALUES('".implode("','", $form_user_blacklist)."')";
//Display ID
echo "<div align='center'> <h4><font color='#10c469'>* A fost adaugat angajatul in baza de date.</font></h4></div>";
}
// run and return the query result resource
return mysql_query($sql);
}
// end utilizatori
// Delete dbRowDelete('my_table', "WHERE id = '$id'");
// End function blacklist gsm
DB創建 - 但它不會添加值 - 這將由空白... 讚賞任何幫助。
請,請,請,請閱讀有關SQL注入和如何防範它。如果你正確地清理你的代碼,我們可以看看它。就目前而言,這是一個巨大的安全漏洞。 –
「請爲我調試我的代碼」不是SE的用途。 – jdv