我必须为我的应用程序实现文本消息功能,因为我有一个PHP文件,我从服务提供商那里需要放置数据库details.and并将其路径给服务提供商添加到服务器中。我很困惑在哪里放置,并根据他,如果我在URL中给文件路径,它应该返回联系电话号码和消息正文,但我无法测试它。混淆在哪里放置php文件(laravel 5.3)
脚本看起来
<?php
// MySQL table outbox:
// CREATE TABLE outbox(sender VARCHAR(255), rcpt VARCHAR(255), body VARCHAR(255));
$mysql_host = "localhost";
$mysql_base = "school_laravel";
$mysql_user = "root";
$mysql_password = "";
$table = "outbox";
mysql_connect($mysql_host, $mysql_user, $mysql_password);
mysql_select_db($mysql_base);
mysql_query("LOCK TABLES $table WRITE, $table AS $table" . "_read READ");
$get_query = "SELECT * FROM $table AS $table" . "_read";
$del_query = "DELETE FROM " . $table;
if ($_GET['device'] != '') {
$suffix = " WHERE sender='" . $_GET['device'] . "'";
$get_query .= suffix;
$del_query .= suffix;
}
$result = mysql_query($get_query);
echo '<messages>';
while ($array = mysql_fetch_array($result)) {
echo '<message msisdn="' . $array['rcpt'] . '">' . $array['body'] . "</message>\n";
}
mysql_query($del_query);
mysql_query("UNLOCK tables");
echo '</messages>';
?>
我的问题是,我应该在哪里把它放在laravel目录,并有可能正如我所提到的上述脚本DB细节得到一个表的详细信息。
感谢您的帮助
请勿使用'mysql_ *'功能。自v5.5(2013年6月)开始,它们已被弃用,并从v7.0(2015年12月)开始删除。请使用[** mysqli _ ***](https://secure.php.net/manual/en/book.mysqli.php)或[** PDO **](https://secure.php.net /manual/en/book.pdo.php)与[**准备语句**](https://secure.php.net/manual/en/pdo.prepare.php)和[**绑定参数** ](https://secure.php.net/manual/en/pdostatement.bindparam.php)。 –
您的代码易受[** SQL注入**](https://en.wikipedia.org/wiki/SQL_injection)攻击。你应该使用[** mysqli **](https://secure.php。net/manual/en/mysqli.prepare.php)或者[** PDO **](https://secure.php.net/manual/en/pdo.prepared-statements.php)准备了具有所述绑定参数的语句在[**这篇文章**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)。 –
请任何人都可以给它作为答案使用PDO或其他东西 –