Archive for 三月, 2013

0327Prog

3-Tier PHP數據庫程式設計

3-Tier PHP數據庫程式設計

使用PHP MySQL library連結資料庫

使用PHP MySQL library連結資料庫

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , ,

27
三月

程式設計二程式 03/27: ex3-main.php

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

session_start();
if(!isset($_SESSION["auth"]) || $_SESSION["auth"] == false)
{
	header('Location: ex3-login.php');
	exit;
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

include "ex3-mysqlauth.php"; 
if (CheckUser($userName,$userPwd))

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

<?php
function CheckUser($userName,$userPwd)
{
	$ret=false;
	$link=mysql_connect("aiplab.net", "asia", "0327") or die(mysql_error());
	mysql_select_db("coursedb") or die(mysql_error());
 
	$query="SELECT * FROM webuser WHERE username='$userName' AND password='$userPwd'";
    $result=mysql_query($query, $link) or die(mysql_error());
 
	$num_rows = mysql_num_rows($result);
	if ($num_rows==1)
	{
		$ret=true;
	}
 
	mysql_free_result($result);
	mysql_close($link);
 
	return $ret;	
}
?>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

<!--p
session_start();
unset($_SESSION['auth']);
$redir = "ex3-login.php";
header("Location: $redir");-->

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,