我在我的项目中编写代码,但我遇到了问题。我需要将一个函数结果放在变量中并将结果打印到数据库中。但请看我的问题:
我的简单文件来自表单:
<?php
include '../functions.php';
sec_session_start();
include '../run_conn.php';
if(isset($_POST['submit'])) {
$publisher = $_POST['publisher']; //THE PROBLEM IS HERE!!!
$title = $_POST['title'];
$tag = $_POST['tag'];
$type = $_POST['type'];
$text = $_POST['text'];
$query = 'INSERT INTO `posts` (`publisher`, `title`, `tag`, `type`, `text`) VALUES (?,?,?,?,?)';
//inserisco l'id utente ovunque
//
$params = array($publisher, $title, $tag, $type, $text);
/* $id_usr_1 = $_POST['id_usr_1'];
$id_usr_2 = $_POST['id_usr_2'];
$text = $_POST['text'];
$query = 'INSERT INTO `chat_t3` (`id_usr_1`, `id_usr_2`, `text`) VALUES (?,?,?)';
//inserisco l'id utente ovunque
//
$params = array($id_usr_1, $id_usr_2, $text);
*/
$results = dataQuery($query, $params);
// for testing only
echo 1 == $results ? 'Ok ' : 'fallito';
}
if ($results == true){
header('location: ../../admin/users.php');
echo 'Tutto fatto, ora puoi eseguire tornare alla schermata precedente!';
} else {
}
?>
现在我需要知道如何将$publisher = $_POST['publisher'];
转换为$publisher = echo get_talkm3_email();
。
但我可能无法做到这一点,因为当我尝试加载页面时,它会变成空白。
我是初学者,我不知道自己做错了什么。
函数get_talkm3_email是:
function get_talkm3_email () {
include 'db_connect.php';
$conn = $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
$query = "SELECT email FROM users WHERE email = '{$_SESSION['email']}'";
$result = $conn->query($query);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["email"];
}
} else {
echo "Si è verificato un errore, non ho trovato nulla";
}
}
&#13;