Archive for 五月, 2015

25
五月

程式設計二程式 05/25: ex7

   Posted by: admin    in 103(下)程式設計(二)

//ex7-login.php

<?php

$message=”請輸入密碼”;

if(isset($_POST["Submit"])){

//

$Usename=$_POST["Usename"];

$Password=$_POST["Password"];

if ($Usename == “abc” && $Password ==”123″)

{

session_start();

$_SESSION['auth'] = true;//認證成功,設定一個session變數

header(’Location: ex7.php’);

exit;

}

else

{

$message=”帳號或密碼錯誤”;

}

}

?>

<form action=”ex7-login.php” method=”post”>

<table width=”200″ border=”1″>

<tr>

<td>帳號</td>

<td><input type=”text” name=”Usename” ></td>

<td><?php echo $message?> </td>

</tr>

<tr>

<td>密碼</td>

<td><input type=”password” name=”Password”></td>

<td><input type=”submit” name=”Submit” value=”登入” /></td>

</tr>

</table>

</form>

//ex7.php

<h1>ex7-登入/登出網站的PHP程式</h1>

<img src=”001-03.png” width=”974″ height=”150″ />

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

11
五月

程式設計二程式 05/11: ex6

   Posted by: admin    in 103(下)程式設計(二)

//ex6.htm
<h1>Ex6</h1>
<form action=”ex6.php” method=”post”>
姓名<input name=”SName” type=”text” />
<input name=”Sbumit” type=”submit”  value=”送出”/>
</form>
//ex6.php
<?php
$Var1=$_POST["SName"];
?>
<h1>Ex6</h1>
<?php echo $Var1; ?>, 您好。

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

4
五月

程式設計二程式 05/04: 期中考

   Posted by: admin    in 103(下)程式設計(二)

import java.io.*;
//Mid1a
		int a, b, c, all;
		a = Integer.parseInt(args[0]);
		all = a * 5 + b * 2 + c;
		System.out.printf("input=(%d, %d, %d) ans = %d", a, b, c, all);
//Mid1b
import java.io.*;
public class Mid1b {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try{
			FileWriter writer = new FileWriter("package.txt");
			PrintWriter pw = new PrintWriter(writer);
            int largeCount = 1000/5;
			for (int i=largeCount;  i>=0;  i--)
			{
				int j = (1000 - 5 * i)/2;
				System.out.printf("Large= %3d Small = %3d\n" , i, j);
				pw.printf("Large= %3d Small = %3d" , i, j);pw.println();
			} 
			pw.close();
 
		}
		catch(FileNotFoundException fe)
	    {
	         System.out.printf(fe.getMessage());
	    }
	    catch(IOException ie)
	    {
	         System.out.printf(ie.getMessage());
	    }
	}
 
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,