「Chifu」的全部文章

[第12堂] 期末成果

  1. 鄭向晴 o
  2. 翁啟銘     blog會員新增,刪除  (php + mysql)
  3. 陳君涵     VIP會員資料查詢 (asp.net + sqlite)
  4. 于裕正     學生加退選系統 (php + sqlite)
  5. 陳明輝 x
  6. 連庭樞     PicMe (php + mysql)  http://220.135.17.70/picme/index.php
  7. 吳慶芳 o
  8. 王贏德     股票查詢系統 (asp.net + sqlite)
  9. 林育瑩 x
  10. 陳友禮     股票查詢系統 (asp.net + sqlite)
  11. 李韓生     股票查詢系統 (asp.net + sqlite)

[第11堂] 課程範例

login1.php

<html>
<form action="login2.php" method="post" name="form1″><br>
Input your data:<br>
<input name="name" type="text" value=""><br>
<input name="pwd" type="text" value=""><br>
<input name="email" type="text" value=""><br>
<input name="submit" type="submit" value="GO"><br>
</form>
</html>

——————————-

login2.php

<?php
session_start();
$_SESSION[“name"]=$_POST[“name"];
$_SESSION[“pwd"]=$_POST[“pwd"];
$_SESSION[“email"]=$_POST[“email"];
echo “name:".$_SESSION[“name"]."<br>";
echo “pwd:".$_SESSION[“pwd"]."<br>";
echo “email:".$_SESSION[“email"]."<br>";
?>

————————-

WebForm1.aspx

protected void Button1_Click(object sender, EventArgs e)
{
Session.Add(“name", TextBox1.Text);
Session.Add(“pwd", TextBox2.Text);
Session.Add(“email", TextBox3.Text);

//重新導向新的頁面
Response.Redirect(“WebForm2.aspx");
}

————————

WebForm2.aspx

//於page_load執行下列程式碼

if (Session[“name"] != null)
{
Response.Write(“name:" + Session[“name"].ToString()+"<br>");
Response.Write(“pwd:" + Session[“pwd"].ToString() + “<br>");
Response.Write(“email:" + Session[“email"].ToString() + “<br>");
}
else
{
Response.Write(“no session data");
}

Count 範例

if(count($_POST)>0 && $_POST[“submit"]=="Count") {

$pdoStatement = $pdo->prepare(“SELECT Count(*) as count FROM address_book“);
$pdoStatement->execute();

//撈資料
while($row = $pdoStatement->fetch(PDO::FETCH_ASSOC) ) {
echo “count=".$row[count];
}
}

[第五堂] PHP POST & GET 九九乘法範例

GET    http://140.112.31.82/example.php?val=9

<?php
if(count($_GET)>0){
for($i=1;$i<=$_GET[“val"];$i++){
for($j=1;$j<=$_GET[“val"];$j++){
echo “$i*$j=".$i*$j."<br>";
}
echo “=======<br>";
}
}
?>

POST    http://140.112.31.82/example2.php

<form action="" method="post" name="form1″><br>
Please input value:
<input name="val" type="text" value="9″>
<input name="submit" type="submit" value="ok"><br>

<?php
if(count($_POST)>0){
for($i=1;$i<=$_POST[“val"];$i++){
for($j=1;$j<=$_POST[“val"];$j++){
echo “$i*$j=".$i*$j."<br>";
}
echo “=======<br>";
}
}
?>

[第四堂] php & sqlite 範例

<form action="" method="post" name="form1″><br>
Input address book data:<br>
<input name="name" type="text" value="shinder"><br>
<input name="phone" type="text" value="0918981520″><br>
<input name="address" type="text" value="Taipei"><br>
<input name="submit" type="submit" value="Add"><br>

<?php

//建立資料連線物件
$pdo = new PDO(“sqlite:mydb.sqlite");

$pdo->exec(“CREATE TABLE address_book (
sid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL ,
name VARCHAR,
phone VARCHAR,
address VARCHAR,
creation_date DATETIME DEFAULT CURRENT_TIMESTAMP)");
if(count($_POST)>0) {
// 準備新增資料的語法
$name = $_POST[“name"];
$phone = $_POST[“phone"];
$address = $_POST[“address"];
$pdo->exec(“INSERT INTO ‘address_book’ (‘name’, ‘phone’, ‘address’ )
VALUES( ‘$name’, ‘$phone’, ‘$address’)");
}

$pdoStatement = $pdo->prepare(“SELECT * FROM address_book");
$pdoStatement->execute();
$arr;
while($row = $pdoStatement->fetch(PDO::FETCH_ASSOC) ) {
print_r( $row );
}

 

 

課程投影片