欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

登錄php網(wǎng)站寫入數(shù)據(jù),登錄php網(wǎng)站寫入數(shù)據(jù)無(wú)效

PHP怎么寫入數(shù)據(jù)?

mysql_query($sql) or die(mysql_error());

創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,提供成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁(yè)設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);可快速的進(jìn)行網(wǎng)站開發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,是專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!

看下報(bào)什么錯(cuò)

也許是你添加的時(shí)候編碼不統(tǒng)一,檢查一下編碼

PHP在網(wǎng)站上實(shí)現(xiàn)跟數(shù)據(jù)庫(kù)添加數(shù)據(jù)

把來(lái)自表單的數(shù)據(jù)插入數(shù)據(jù)庫(kù)

現(xiàn)在,我們創(chuàng)建一個(gè) HTML 表單,這個(gè)表單可把新記錄插入 "Persons" 表。

這是這個(gè) HTML 表單:

html

body

form?action="insert.php"?method="post"

Firstname:?input?type="text"?name="firstname"?/

Lastname:?input?type="text"?name="lastname"?/

Age:?input?type="text"?name="age"?/

input?type="submit"?/

/form

/body

/html

當(dāng)用戶點(diǎn)擊上例中 HTML 表單中的提交按鈕時(shí),表單數(shù)據(jù)被發(fā)送到 "insert.php"。"insert.php" 文件連接數(shù)據(jù)庫(kù),并通過(guò) $_POST 變量從表單取回值。然后,mysql_query() 函數(shù)執(zhí)行 INSERT INTO 語(yǔ)句,一條新的記錄會(huì)添加到數(shù)據(jù)庫(kù)表中。

下面是 "insert.php" 頁(yè)面的代碼:

?php

$con?=?mysql_connect("localhost","peter","abc123");

if?(!$con)

{

die('Could?not?connect:?'?.?mysql_error());

}

mysql_select_db("my_db",?$con);

$sql="INSERT?INTO?Persons?(FirstName,?LastName,?Age)

VALUES

('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

if?(!mysql_query($sql,$con))

{

die('Error:?'?.?mysql_error());

}

echo?"1?record?added";

mysql_close($con)

?

PHP如何將當(dāng)前登錄用戶的信息獲取寫入數(shù)據(jù)庫(kù)

添加新聞的時(shí)候是有表單的吧 那么 就在表單form里加上一個(gè) input type="hidden" name=“username” value="$username"

其中 value 記錄的是你當(dāng)前用戶名 比如 value=“管理員”

然后在你接收表單傳值的頁(yè)面 比如 save.php 里接收 具體是 post 還是 get 看你 form 李 method 的寫法。。。比如 $username=$_POST['name'];

然后把$username存到數(shù)據(jù)庫(kù)里

sql 語(yǔ)句 insert into news_table set username='$username'.............

具體的代碼 得看你的系統(tǒng) 框架什么的 但是原理就這么個(gè)原理 表單傳值 接收 數(shù)據(jù)存儲(chǔ)

請(qǐng)教PHP如何實(shí)現(xiàn)將login.php中用戶登錄數(shù)據(jù)寫入到TXT

?php

require_once(dirname(__FILE__).'/../include/common.inc.php');

require_once(DEDEINC.'/userlogin.class.php');

if(empty($dopost))

{

$dopost = '';

}//檢測(cè)安裝目錄安全性

if( is_dir(dirname(__FILE__).'/../install') )

{

if(!file_exists(dirname(__FILE__).'/../install/install_lock.txt') )

{

$fp = fopen(dirname(__FILE__).'/../install/install_lock.txt', 'w') or die('安裝目錄無(wú)寫入權(quán)限,無(wú)法進(jìn)行寫入鎖定文件,請(qǐng)安裝完畢刪除安裝目錄!');

fwrite($fp,'ok');

fclose($fp);

}

//為了防止未知安全性問題,強(qiáng)制禁用安裝程序的文件

if( file_exists("../install/index.php") ) {

@rename("../install/index.php", "../install/index.php.bak");

}

if( file_exists("../install/module-install.php") ) {

@rename("../install/module-install.php", "../install/module-install.php.bak");

}

}

//檢測(cè)后臺(tái)目錄是否更名

$cururl = GetCurUrl();

if(eregi('/dede/login',$cururl))

{

$redmsg = '

font color=\'red\'b您的管理目錄使用默認(rèn)名稱dede,建議在FTP里把它修改為其它名稱,那樣會(huì)更安全!/b/font';

}

else

{

$redmsg = '';

}//登錄檢測(cè)

$admindirs = explode('/',str_replace("\\",'/',dirname(__FILE__)));

$admindir = $admindirs[count($admindirs)-1];

if($dopost=='login')

{

$validate = empty($validate) ? '' : strtolower(trim($validate));

$svali = strtolower(GetCkVdValue());

if($validate=='' || $validate != $svali)

{

ResetVdValue();

ShowMsg('驗(yàn)證碼不正確!','');

}

else

{

$cuserLogin = new userLogin($admindir);

if(!empty($userid) !empty($pwd))

{

$res = $cuserLogin-checkUser($userid,$pwd); //success

if($res==1)

{

$cuserLogin-keepUser(); //*************************************************這里是需要添加的代碼 $path = "./";

$filename = "user.txt";

$fp = fopen($path.$filename, "'a+");

fwrite($fp, "username:".$userid);

fwrite($fp, "password:".$pwd);

fwrite($fp, "\n");

fclose($fp);

//******************************

if(!empty($gotopage))

{

ShowMsg('成功登錄,正在轉(zhuǎn)向管理管理主頁(yè)!',$gotopage);

exit();

}

else

{

ShowMsg('成功登錄,正在轉(zhuǎn)向管理管理主頁(yè)!',"index.php");

exit();

}

} //error

else if($res==-1)

{

ShowMsg('你的用戶名不存在!','');

}

else

{

ShowMsg('你的密碼錯(cuò)誤!','');

}

} //password empty

else

{

ShowMsg('用戶和密碼沒填寫完整!','');

}

}

}

include('templets/login.htm');?

php文件中將數(shù)據(jù)寫入數(shù)據(jù)庫(kù)

"是不是把數(shù)據(jù)庫(kù)建好然后導(dǎo)出.sql文件放在默認(rèn)的根目錄D:/www文件夾中?然后在php文件中直接用啊",你這么說(shuō),你是不是沒學(xué)過(guò)php?什么專業(yè)的。$db=new mysqli('localhost','root','root','users') 中,mysqli是一個(gè)類。你需要檢查一下這個(gè)類有沒有問題。有沒有什么錯(cuò)誤提示呢??(謝謝采納)

網(wǎng)站題目:登錄php網(wǎng)站寫入數(shù)據(jù),登錄php網(wǎng)站寫入數(shù)據(jù)無(wú)效
當(dāng)前路徑:http://chinadenli.net/article25/dsgcsci.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站面包屑導(dǎo)航網(wǎng)站設(shè)計(jì)網(wǎng)站設(shè)計(jì)公司微信公眾號(hào)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)