我正在尝试将个人消息传递系统构建到我的项目中。到目前为止,我一直在项目中使用 MYSQLi,我刚刚找到了 PMS 的这段代码。现在我不知道如何将这个mysql代码转换成mysqli ..
<?php
session_start();
$message = $_POST['forward2'];
if (isset($_POST['submit']))
{
// if the form has been submitted, this inserts it into the Database
$to_user = $_POST['to_user'];
$from_user = $_POST['from_user'];
$message = $_POST['message'];
mysql_query("INSERT INTO messages (to_user, message, from_user) VALUES ('$to_user', '$message', '$from_user')")or die(mysql_error());
echo "PM succesfully sent!";
}
else
{
// if the form has not been submitted, this will show the form
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0">
<tr><td colspan=2><h3>Send PM:</h3></td></tr>
<tr><td></td><td>
<input type="hidden" name="from_user" maxlength="32" value = <?php echo $_SESSION['username']; ?>>
</td></tr>
<tr><td>To User: </td><td>
<input type="text" name="to_user" maxlength="32" value = "">
</td></tr>
<tr><td>Message: </td><td>
<TEXTAREA NAME="message" COLS=50 ROWS=10 WRAP=SOFT></TEXTAREA>
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Send Message">
</td></tr>
</table>
</form>
<?php
}
?>