美好的一天,我試圖使用PHP它有點工作將數據插入到MySQL表,但我不能看到數據在phpMyAdmin蹊蹺的數據插入
<?php
$con=mysqli_connect('localhost','root','');
if(!$con)
{
echo("not connected");
}
if(!mysqli_select_db($con,'exam'))
{
echo 'db not selected';
}
$header = $_POST['header'];
$date = $_POST['date'];
$categ = $_POST['categ'];
$moder = $_POST['moder'];
$posttxt = $_POST['posttxt'];
$theme = $_POST['theme'];
$author = $_POST['author'];
$sql = "INSERT INTO postex (header,date,categ,moder,posttxt,theme,author) VALUES ('$header','$date','$categ','$moder','$posttxt','$theme','$author')";
if
(empty($header) || empty($date) || empty($categ) || empty($moder) || empty($posttxt) || empty($theme) || empty($author))
{
echo "<Br>feel the fields!!!";
}
else{
echo("<br>added,wait for redirect");
}
?>
你不執行你的查詢,你只是定義一個字符串。但是當你這樣做時,你將會遇到一個sql注入問題。 – jeroen
那我該如何執行它? – Michael97
你應該從手冊開始...... – jeroen