亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

值1存儲在數據庫中,而不是文本框值/ PHP-MySql

值1存儲在數據庫中,而不是文本框值/ PHP-MySql

PHP
UYOU 2021-05-12 17:23:19
好吧,我想將3個文本框值存儲到我的mysqli數據庫中,運行這些代碼后什么都沒有發生!如果發生任何情況,則將數字“ 1”存儲到數據庫中,而不是“文本框值”PHP代碼:<?phpinclude 'displaycustomersdb.php'; //this file give $Ccode from user sessions and config.php is in it.global $textareamsg;global $title;global $reciver;global $sender;$textareamsg = (isset($_GET['textarea']));$title = (isset($_GET['title']));$reciver = (isset($_GET['reciver']));if (isset($_GET['sendmsg'])) {    $sql_msg = mysqli_query($link, 'INSERT INTO messaging (title, message, sender, reciver) VALUES (' . $title . ',' . $textareamsg . ',' . $Ccode . ',' . $reciver . '');}?>HTML代碼:<?php include 'sendmsg.php'; ?><form method="get">  <i class="fas fa-envelope-open-text"></i><input type="text" placeholder="Ttitle here ..." name="title">  <br>  <br>  <i class="fas fa-user-plus"></i><input type="text" placeholder="TO" name="reciver">  <br>  <br>  <textarea rows="10" cols="100" placeholder="textarea" name="textarea" style="padding:10px;"></textarea>  <br>  <br>  <button type="submit" name="sendmsg"><i class="far fa-share-square"></i>Insert</button></form>
查看完整描述

3 回答

?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

您將獲得布爾值,而不是值本身。請記住,如果給定值存在并且將其存儲為1則isset()返回true。我想您打算檢查值是否存在,請按照以下步驟操作:


$textareamsg = isset($_GET['textarea'])? $_GET['textarea'] : '';

$title = isset($_GET['title'])? $_GET['title'] : '';

$reciver = isset($_GET['reciver'])? $_GET['reciver']: '';

而且您還應該存儲這樣的字符串值:


if (isset($_GET['sendmsg'])) {

    $sql_msg = mysqli_query($link, 'INSERT INTO messaging (title, message, sender, reciver) VALUES ("' . $title . '","' . $textareamsg . '","' . $Ccode . '","' . $reciver . '"');

}

希望對您有所幫助:)


查看完整回答
反對 回復 2021-05-28
?
夢里花落0921

TA貢獻1772條經驗 獲得超6個贊

好,謝謝大家。我確實嘗試過,并且可以正常工作:


$textareamsg = $_GET['textarea'];

$title      =  $_GET['title'];

$reciver    =  $_GET['reciver'];


if (isset($_GET['sendmsg'])) {

    $sql_msg = mysqli_query($link, "INSERT INTO messaging (title, message, sender, reciver) VALUES ('$title','$textareamsg', '$ccode','$reciver')");

}


查看完整回答
反對 回復 2021-05-28
?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

我認為您的單引號弄亂了您的查詢語法。
這里開始,您的值必須在PHP中像這樣引用

$sql_msg = mysqli_query($link, "INSERT INTO messaging (title, message, sender, reciver) VALUES ('$title', '$textareamsg', '$Ccode', '$reciver')";


如果給定值存在并且將其存儲在數據庫中,則isset()返回true,其值為1

查看完整回答
反對 回復 2021-05-28
  • 3 回答
  • 0 關注
  • 200 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號