php之從資料庫中獲取資料例項

2021-07-16 03:31:28 字數 3680 閱讀 4907

此小型專案是為了讓商家能通給過乙個網頁得到客戶的資訊,並存在資料庫中,同時根據這些資訊給客戶傳送郵件,實時推送產品以及商業活動。

分析如下:

首先得有乙個客戶登入頁面即kehudengji.html

其次得有乙個收集並儲存客戶資料的php檔案即kehudengji.php

再有商家自己傳送郵件的頁面即fasongyoujian.html

最後得有從資料庫中獲取客戶資訊的php檔案即fasongyoujian.php

程式如下

kehudengji.html

html>

lang=

"en">

charset=

"utf-8">

title>

head>

action=

"kehudengji.php"method=

"post"target=

"_blank"style=

"width:400

px;margin:0

auto;>

for=

"name

">您的名字是:

label>

type=

"text"id=

"name"name=

"name"/>

for=

"phone">您的**是:

label>

type=

"text"id=

"phone"name=

"phone"/>

for=

"email">您的郵箱是:

label>

type=

"text"id=

"email"name=

"email"/>

style=

"margin-left: 60

px;">提交

button>重置

button>

form>

body>

html>

kehudengji.php

<?php

$name=$_post["name"];

$phone=$_post["phone"];

$email=$_post["email"];

echo"thanks for submitting the form!

";echo "您的名字是:".$name."

";echo "您的**是:".$phone."

";echo "您的**是:".$email."

";$link=mysql_connect("127.0.0.1","root","root")

or die("連線失敗!");

mysql_select_db("php",$link);

$it="insert into shangdiankaiye value('$name','$phone','$email')";

$result=mysql_query($it,$link)

or die("建立資料表失敗!".mysql_error());

mysql_close($link);

?>

fasongyoujian.html

html>

lang=

"en">

charset=

"utf-8">

title>

head>

action=

"fasongyoujian.php"method=

"post"target=

"_blank"style=

"width:400

px;margin:0

auto;>

for=

"subject

">傳送主題:

label>

type=

"text"id=

"subject"name=

"subject">

for=

"body">主要內容:

label>

name=

"body"id=

"body"cols=

"30"rows=

"20">textarea>

style=

"margin-left: 60

px;">提交

button>重置

button>

form>

body>

html>

fasongyoujian.php

<?php

$subject=$_post["subject"];

$body=$_post["body"];

echo "您的傳送主題是:".$subject."

";echo "您的主要內容是:".$body."

";$link=mysql_connect("127.0.0.1","root","root")

or die("連線失敗!");

mysql_select_db("php",$link);

$st="select * from shangdiankaiye";

$result=mysql_query($st,$link)

or die("建立資料表失敗!".mysql_error());

while($row=mysql_fetch_array($result))

mysql_close($link);

?>

但不得不提的是,此時郵件是發不出去的,接下來,我將會解決這個問題。

ASP從資料庫中獲取檔案

資料庫的表info,表部分結構 info id int 主鍵 file mime type varchar 50 檔案mime型別 file size int 檔案大小 info file image 檔案 下列 的檔名 getfile.asp language vbscript info id r...

ASP從資料庫中獲取檔案

資料庫的表info,表部分結構 info id int 主鍵 file mime type varchar 50 檔案mime型別 file size int 檔案大小 info file image 檔案 下列 的檔名 getfile.asp language vbscript info id r...

如何從HITRAN資料庫 獲取資料

最近研究了一下hitran 資料庫,在網路上關於hitran 的介紹不是很多,而且有點不太詳細。所以這篇部落格就從小白的角度介紹一下hitran 資料庫以及從中獲取資料的方法。hitran資料庫是光譜引數的彙編,用於模擬和分析氣態介質 尤其是陸地大氣 中的光的傳輸和發射。自1960年代末成立以來 當...