大家好,我有以下代码创建一个简单的PHP私人消息,我在下面发送表单
<form enctype="multipart/form-data" method="POST" action="send.php">
<label>To</label>
<select name="To" class="form-control">
<option value="user">user</option>
<option value="user1">user1</option>
</select>
<input type="hidden" name="From" value="<?php $_SESSION['user'];?>">
<label>Subject</label>
<input type="text" name="Subject" placeholder="Subject">
<label>Message</label>
<textarea class="form-control" cols="40" name="Message" placeholder="Message" rows="10"></textarea>
<input type="hidden" name="Date" value="<?php date("F j, Y, g:i a"); ?>">
<button type="submit" name="Send" class="btn btn-success">Send</button></form>
我的php代码如下:
<?php
session_start();
include 'db.php';
if(isset($_POST['Send'])){
$To = $_POST['To'];
$From = $_POST['From'];
$Sub = $_POST['Subject'];
$Mess = $_POST['Message'];
$Date = $_POST['Date'];
$sql = "INSERT INTO pm from, to, sub, mess, date VALUES '$From', '$To', '$Sub', '$Mess', '$Date'";
$result = mysqli_query($con, $sql);
if($result == true){
$sent = "Message sent Successfully";
header("Location: Home.php?message=$sent");
}
else{
$ntsent = "Message not sent Successfully";
header("Location: Home.php?message=$ntsent");
}
mysqli_close($con);
}
?>
它总是说消息没有成功发送消息你能猜出是什么问题吗?
答案 0 :(得分:0)
我认为您的INSERT查询不完整。试试这个
[key: string]: any;