|
|
|
สร้างเว็บศิษย์เก่า มีการสมัครสมาชิกจาก รหัสนักศึกษา ที่มีในฐานข้อมูลแล้ว |
|
|
|
|
|
|
|
ตามโค๊ด พอผมใส่รหัสไป มันจะไปโชว์ ข้อมูลแรกสุดในดาต้าเบส ไม่ได้แสดงข้อมูลที่ต้องการจะอัพเดทครับ ผมใส่ 540510 มันจะโชว์ ข้อมูลแรกคือ 41051 พอจะมีวิธีแก้ไหมครับ
หน้าตรวจสอบ รหัส
Code (PHP)
<?php require_once('Connections/DbConnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['txt1'])) {
$loginUsername=$_POST['txt1'];
$password=$_POST['txt2'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "profile.php";
$MM_redirectLoginFailed = "register.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_DbConnect, $DbConnect);
$LoginRS__query=sprintf("SELECT al_no, al_pass FROM member WHERE al_no=%s AND al_pass=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $DbConnect) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
$checkid = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['txt3'])) {
$loginUsername=$_POST['txt3'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "register2.php";
$MM_redirectLoginFailed = "register.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_DbConnect, $DbConnect);
$LoginRS__query=sprintf("SELECT al_no FROM member WHERE al_no=%s",
GetSQLValueString($loginUsername, "text"));
$LoginRS = mysql_query($LoginRS__query, $DbConnect) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MD_Usernames'] = $loginUsername;
$_SESSION['MD_UserGroups'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>register</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css">
<link rel="stylesheet" type="text/css" href="css/form.css" />
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="phonegap.js"></script>
<script src="jquery.mobile-1.3.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#contact"></a></li>
<li class="active"><a href="#">หน้าหลัก</a></li>
<li><a href="#contact">เกี่ยวกับเรา</a></li>
<li><a href="#contact">เว็บบอร์ด</a></li>
<li><a href="#contact">กิจกรรม</a></li>
</ul>
<form action="<?php echo $loginFormAction; ?>" onSubmit="return validate_form(this)" method="POST"class="navbar-form navbar-right" role="form">
<div class="form-group">
<label class="sr-only" for="exampleInputUsername">Username</label>
<input name="txt1" type="Username" class="form-control" id="55" placeholder="ID">
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input name="txt2" type="password" class="form-control" id="55" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Login</button>
</form>
</div>
</nav>
</div>
<!-- ====================================================================================================================================== -->
<br></br>
<center>
<div class="col-sm-6 col-md-4 "></div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<form action="<?php echo $checkid; ?>" onSubmit="return validate_form(this)" method="POST" class="form-horizontal" role="form">
<h2 class="page-header">สมัครสมาชิก</h2>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="formGroupInputSmall" >รหัสนักศึกษา :</label>
<div class="col-sm-8">
<input name="txt3" type="text" class="form-control" id="55" placeholder="รหัสนักศึกษา" required autofocus>
</div>
</div>
<button type="submit" class="btn btn-default">ตรวจสอบ</button>
</div>
</form>
</div>
</div>
</div
>
<p> </p>
</center>
</body>
</html>
หน้าอัพเดท (หลังจาก ตรวจสอบได้แล้ว)
Code (PHP)
<?php session_start(); ?>
<?php require_once('Connections/DbConnect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['txt1'])) {
$loginUsername=$_POST['txt1'];
$password=$_POST['txt2'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "profile.php";
$MM_redirectLoginFailed = "register.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_DbConnect, $DbConnect);
$LoginRS__query=sprintf("SELECT al_no, al_pass FROM member WHERE al_no=%s AND al_pass=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $DbConnect) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>register</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css">
<link rel="stylesheet" type="text/css" href="css/form.css" />
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="phonegap.js"></script>
<script src="jquery.mobile-1.3.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#contact"></a></li>
<li class="active"><a href="#">หน้าหลัก</a></li>
<li><a href="#contact">เกี่ยวกับเรา</a></li>
<li><a href="#contact">เว็บบอร์ด</a></li>
<li><a href="#contact">กิจกรรม</a></li>
</ul>
<form action="<?php echo $loginFormAction; ?>" onSubmit="return validate_form(this)" method="POST"class="navbar-form navbar-right" role="form">
<div class="form-group">
<label class="sr-only" for="exampleInputUsername">Username</label>
<input name="txt1" type="Username" class="form-control" id="55" placeholder="ID">
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input name="txt2" type="password" class="form-control" id="55" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Login</button>
</form>
</div>
</nav>
</div>
<!-- ====================================================================================================================================== -->
<br></br>
<center>
<div class="col-sm-6 col-md-4 "></div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<form name="form" onSubmit="return validate_form(this)" method="POST" class="form-horizontal" role="form">
<h2 class="page-header">สมัครสมาชิก</h2>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="formGroupInputSmall" >รหัสนักศึกษา :</label>
<div class="col-sm-8">
<input name="al_no" type="text" disabled class="form-control" id="al_no" placeholder="รหัสนักศึกษา" required="required" autofocus="autofocus">
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="formGroupInputSmall" >Password :</label>
<div class="col-sm-8">
<input name="al_pass" type="text" class="form-control" id="al_pass" placeholder="" required autofocus>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label">Email :</label>
<div class="col-sm-8">
<input name="email" type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="formGroupInputSmall">Confirm Email :</label>
<div class="col-sm-8">
<input name="conemail" type="email" class="form-control" id="inputEmail3" placeholder="Confirm Email address">
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="formGroupInputSmall" for="disabledTextInput" >
คำถาม :
</label>
<div class="col-sm-8">
<select name="q1" class="form-control" id="q1" >
<option>คำถาม</option>
<option>คุณชื่ออะไร</option>
<option selected>คุณจบสาขาอะไร</option>
<option>คุณชอบกินอะไร</option>
<option>คุณชอบสัตว์อะไร</option>
</select>
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="formGroupInputSmall">คำตอบ :</label>
<div class="col-sm-8">
<input name="anwser" type="text" class="form-control" id="anwser" placeholder="คำตอบ">
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-4 control-label" for="formGroupInputSmall"></label>
<div class="col-sm-8">
<button type="submit" class="btn btn-default">ยืนยัน</button>
<button type="reset" class="btn btn-default">ยกเลิก</button>
</div>
</div>
</form>
<form method="post" name="form1">
</form>
<p> </p>
</div>
</div>
</div>
</div
>
<p> </p>
</center>
</body>
<html>
Tag : PHP
|
|
|
|
|
|
Date :
2014-10-20 02:41:03 |
By :
peekungbaba |
View :
1213 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จริงหรือเปล่าแอดมิน อย่างนี้คุณเอาพาสสมาชิกไปแอบ Login แอคเค้าอื่นได้สบายๆเลยดิ คนส่วนใหญ่ใช้พาสเดียวกันหมดอยู่แล้ว
|
|
|
|
|
Date :
2014-10-21 12:43:59 |
By :
ทำไมทำแบบนี้ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|