|
|
|
จะส่งค่า ID ไปเเก้ไขยังไงคับ ช่วยทีคับ จะส่งค่า ID ไปเเก้ไขยังไงคับ ช่วยทีคับ จะส่งค่า ID ไปเเก้ไขยังไงคับ ช่วยทีคับ |
|
|
|
|
|
|
|
โค้ดการ login เข้าระบบ เเต่มันไม่ยอมส่งค่า ID ของ User นั้นมาให้คับ Login.php
Code (PHP)
<?php
session_start();
if(isset($_GET['logout'])){
unset($_SESSION['id']);
unset($_SESSION['name']);
}
if(isset($_POST['submit'])){
include 'config.php';
mysql_query('SET NAMES UTF8');
$sql = 'SELECT * FROM member WHERE username ="'.$_POST['username'].'" && password = "'.md5($_POST['password']).'"';
$query = mysql_query($sql);
if(mysql_num_rows($query) > 0){
$row = mysql_fetch_array($query);
$_SESSION['id'] = $row['id'];
$_SESSION['name'] = $row['name'];
}
else{
echo '<script>alert("ไม่สามารถเข้าสู่ระบบได้ \n\n\"กรุณาสมัครสมาชิกก่อน\""); location.href= "Login.php";</script>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<!--
Created by Artisteer v2.3.0.25189
Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"
-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>ระบบบริหารคลังวัตถุดิบ</title>
<script type="text/javascript" src="script.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->
</head>
<body>
<div id="art-page-background-simple-gradient"> </div>
<div id="art-page-background-glare">
<div id="art-page-background-glare-image"></div>
</div>
<div id="art-main">
<div class="art-Sheet">
<div class="art-Sheet-tl"></div>
<div class="art-Sheet-tr"></div>
<div class="art-Sheet-bl"></div>
<div class="art-Sheet-br"></div>
<div class="art-Sheet-tc"></div>
<div class="art-Sheet-bc"></div>
<div class="art-Sheet-cl"></div>
<div class="art-Sheet-cr"></div>
<div class="art-Sheet-cc"></div>
<div class="art-Sheet-body">
<div class="art-Header">
<div class="art-Header-png"></div>
<div class="art-Header-jpeg"></div>
<div class="art-Logo">
<h1 id="name-text" class="art-Logo-name"><a href="#">Inventory Management.</a></h1>
<div id="slogan-text" class="art-Logo-text"></div>
</div>
</div>
<div class="art-nav">
<div class="l"></div>
<div class="r"></div>
<ul class="art-menu">
<li class="w60"> </li>
<li>
<a href="#"><span class="l" ></span><span class="r"></span><span class="t">Home</span></a>
<ul>
<li> <a href="http://localhost/PHPProject/Home.php"><span class="l"></span><span class="r"></span><span class="t">Home</span></a> </li>
<il><a href="http://localhost/PHPProject/Login.php"><span class="l"></span><span class="r"></span><span class="t">ข้อมูลผู้ใช้งาน</span></a></il>
</ul>
</li>
<li> <a href="#" ><span class="l"></span><span class="r"></span><span class="t">วัตถุดิบ</span></a>
<ul>
<li><a href="http://localhost/PHPProject/Datamaterial.php">ข้อมูลวัตถุดิบ</a></li>
<li><a href="http://localhost/PHPProject/Detailmaterial.php">ซื้อวัตถุดิบเข้าคลัง</a></li>
<li><a href="http://localhost/PHPProject/Stockmaterial.php">คลังวัตถุดิบ</a></li>
<li><a href="http://localhost/PHPProject/Manual.php">ตัดวัตถุดิบจากคลัง</a></li>
</ul>
</li>
<li> <a href="#"><span class="l"></span><span class="r"></span><span class="t">สินค้า</span></a>
<ul>
<li><a href="http://localhost/PHPProject/Product.php">ข้อมูลสินค้า</a></li>
<li><a href="http://localhost/PHPProject/Order.php">ผลิตสินค้า</a></li>
<li><a href="http://localhost/PHPProject/showingredients.php">ข้อมูลส่วนประกอบสินค้า</a></li>
</ul>
</li>
<li> <a href="#"><span class="l"></span><span class="r"></span><span class="t">ประมาณการซื้อ</span></a>
<ul>
<li><a href="http://localhost/PHPProject/AboutTheDate.php">ประมาณการซื้อจากจำนวนวัน</a></li>
<li><a href="http://localhost/PHPProject/AboutTheProduct.php">ประมาณการซื้อจากจำนวนสินค้า</a></li>
</ul>
</li>
<li> <a href="Login.php?logout" target="_self"><span class="l"></span><span class="r"></span><span class="t">ออกจากระบบ</span></a> </li>
</ul>
</div>
<div class="art-contentLayout">
<div class="art-content">
<div class="art-Post">
<div class="art-Post-tl"></div>
<div class="art-Post-tr"></div>
<div class="art-Post-bl"></div>
<div class="art-Post-br"></div>
<div class="art-Post-tc"></div>
<div class="art-Post-bc"></div>
<div class="art-Post-cl"></div>
<div class="art-Post-cr"></div>
<div class="art-Post-cc"></div>
<div class="art-Post-body">
<div class="art-Post-inner">
<div class="art-PostContent">
<div align="center">
<table class="table" width="100%" height="100" border="0" >
<tr>
<td width="33%" valign="top" colspan="3"></td>
</tr>
</table>
</div>
<?php
if(!isset($_SESSION['id'])){ ?>
<form action="Login.php" method="POST">
<table border="0" align="center">
<tr>
<td><img src="images/Micro-Enterprise-Login.jpg" width="300" height="" /></td>
<td><table border="0">
<tr>
<td>ชื่อในการเข้าระบบ :</td>
<td><input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td>รหัสผ่านในการเข้าระบบ :</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td colspan="2"align="center"><input type="submit" name="submit" value="เข้าสู่ระบบ"/>
<input type="reset" value="ยกเลิก" name="reset" /></td>
</tr>
</table>
</a></td>
</tr>
</table>
</form>
<?php } else { ?>
<table width="600" border="0" align="center" />
<tr>
<td><table border="0">
<tr>
<td><font color="#0000FF">ยินดีต้อนรับผู้ใช้งานระบบ : </font><font color="#FF0000">
<?= $_SESSION['name'] ?></font></td>
</tr>
<tr>
<td><br />
<?
include 'config.php';
$sql = 'SELECT * FROM member WHERE id = "'.$_POST['id'].'" ' ;
$query = mysql_query($sql) or die ("Error Query [".$sql."]");
echo $sql;
?>
<?
while($objResult = mysql_fetch_array($query)) //วนลูปเพื่อแสดงข้อมูลจนครบทุก โดยเก็บข้อมูลไว้ในตัวแปร $objResult ซึ่งเป็นตัวแปรอะเรย์
{
?>
<?
}
?>
+ <a href="editprofile.php?UserID=<?php echo $objResult['id']?>"><font color="#0000CC">แก้ไขข้อมูลผู้ใช้งานระบบ</font></a>:
<font color="#FF0000"><?= $_SESSION['name']?></font></td>
</tr>
<tr>
<td>+ <a href="register.php" target="_self" ><font color="#0000CC">เพิ่มผู้เข้าใช้งานระบบ</font></a></td>
</tr>
</table></td>
<td><table border="0" align="center"/>
<tr>
<td><?
class Paginator{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $high;
var $limit;
var $return;
var $default_ipp;
var $querystring;
var $url_next;
function PaginatorAdmin()
{
$this->current_page = 1;
$this->mid_range = 7;
$this->items_per_page = $this->default_ipp;
$this->url_next = $this->url_next;
}
function paginate()
{
if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
$this->num_pages = ceil($this->items_total/$this->items_per_page);
if($this->current_page < 1 Or !is_numeric($this->current_page)) $this->current_page = 1;
if($this->current_page > $this->num_pages) $this->current_page = $this->num_pages;
$prev_page = $this->current_page-1;
$next_page = $this->current_page+1;
if($this->num_pages > 10)
{
$this->return = ($this->current_page != 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"".$this->url_next.$this->$prev_page."\">« Previous</a> ":"<span class=\"inactive\" href=\"#\">« Previous</span> ";
$this->start_range = $this->current_page - floor($this->mid_range/2);
$this->end_range = $this->current_page + floor($this->mid_range/2);
if($this->start_range <= 0)
{
$this->end_range += abs($this->start_range)+1;
$this->start_range = 1;
}
if($this->end_range > $this->num_pages)
{
$this->start_range -= $this->end_range-$this->num_pages;
$this->end_range = $this->num_pages;
}
$this->range = range($this->start_range,$this->end_range);
for($i=1;$i<=$this->num_pages;$i++)
{
if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
{
$this->return .= ($i == $this->current_page And $_GET['Page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"".$this->url_next.$i."\">$i</a> ";
}
if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
}
$this->return .= (($this->current_page != $this->num_pages And $this->items_total >= 10) And ($_GET['Page'] != 'All')) ? "<a class=\"paginate\" href=\"".$this->url_next.$next_page."\">Next »</a>\n":"<span class=\"inactive\" href=\"#\">» Next</span>\n";
}
else
{
for($i=1;$i<=$this->num_pages;$i++)
{
$this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"".$this->url_next.$i."\">$i</a> ";
}
}
$this->low = ($this->current_page-1) * $this->items_per_page;
$this->high = ($_GET['ipp'] == 'All') ? $this->items_total:($this->current_page * $this->items_per_page)-1;
$this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_pages()
{
return $this->return;
}
}
?>
<html>
<head>
<title></title>
</head>
<style type="text/css">
<!--
.paginate {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
}
a.paginate {
border: 1px solid #000080;
padding: 2px 6px 2px 6px;
text-decoration: none;
color: #000080;
}
h2 {
font-size: 12pt;
color: #003366;
}
h2 {
line-height: 1.2em;
letter-spacing:-1px;
margin: 0;
padding: 0;
text-align: left;
}
a.paginate:hover {
background-color: #000080;
color: #FFF;
text-decoration: underline;
}
a.current {
border: 1px solid #000080;
font: bold .7em Arial, Helvetica, sans-serif;
padding: 2px 6px 2px 6px;
cursor: default;
background:#000080;
color: #FFF;
text-decoration: none;
}
span.inactive {
border: 1px solid #999;
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
padding: 2px 6px 2px 6px;
color: #999;
cursor: default;
}
-->
</style>
<body>
<?
include ('config.php');
$strSQL = "SELECT * FROM member WHERE status LIKE '%admin%' ORDER BY id ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 5; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" LIMIT $Page_Start, $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="305" border="0" bgcolor="#FFFFFF">
<tr>
<th width="190" bgcolor="#0099FF"> <div align="center">ชื่อผู้ใช้งาน </div></th>
<th width="105" bgcolor="#0099FF"> <div align="center">สถานะ</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery)) //วนลูปเพื่อแสดงข้อมูลจนครบทุก โดยเก็บข้อมูลไว้ในตัวแปร $objResult ซึ่งเป็นตัวแปรอะเรย์
{
?>
<tr>
<td bgcolor="#99CCFF"><div align="center" >
<?=trim($objResult["name"]);?>
</div></td>
<td bgcolor="#99CCFF"><div align="center" >
<? if($objResult["status"]=="admin")
{
echo "<font color='green'>Admin</font>";
}elseif($objResult["status"]=="user")
{
echo "<font color='red'>User</font>";
};
?>
</div></td>
</tr>
<?
}
?>
</table>
<br>
จำนวนผู้ใช้งานระบบทั้งหมด :
<?= $Num_Rows;?>
หน้า :
<?
$pages = new Paginator;
$pages->items_total = $Num_Rows;
$pages->mid_range = 10;
$pages->current_page = $Page;
$pages->default_ipp = $Per_Page;
$pages->url_next = $_SERVER["PHP_SELF"]."?QueryString=value&Page=";
$pages->paginate();
echo $pages->display_pages()
?>
</body>
</html>
</td>
</tr>
</table>
</td>
<tr>
<td></td>
<td><table border="0" align="center">
<tr>
<td><?
class PaginatorUser{
var $items_per_page;
var $items_total;
var $current_page;
var $num_pages;
var $mid_range;
var $low;
var $high;
var $limit;
var $return;
var $default_ipp;
var $querystring;
var $url_next;
function Paginator()
{
$this->current_page = 1;
$this->mid_range = 7;
$this->items_per_page = $this->default_ipp;
$this->url_next = $this->url_next;
}
function paginate()
{
if(!is_numeric($this->items_per_page) OR $this->items_per_page <= 0) $this->items_per_page = $this->default_ipp;
$this->num_pages = ceil($this->items_total/$this->items_per_page);
if($this->current_page < 1 Or !is_numeric($this->current_page)) $this->current_page = 1;
if($this->current_page > $this->num_pages) $this->current_page = $this->num_pages;
$prev_page = $this->current_page-1;
$next_page = $this->current_page+1;
if($this->num_pages > 10)
{
$this->return = ($this->current_page != 1 And $this->items_total >= 10) ? "<a class=\"paginate\" href=\"".$this->url_next.$this->$prev_page."\">« Previous</a> ":"<span class=\"inactive\" href=\"#\">« Previous</span> ";
$this->start_range = $this->current_page - floor($this->mid_range/2);
$this->end_range = $this->current_page + floor($this->mid_range/2);
if($this->start_range <= 0)
{
$this->end_range += abs($this->start_range)+1;
$this->start_range = 1;
}
if($this->end_range > $this->num_pages)
{
$this->start_range -= $this->end_range-$this->num_pages;
$this->end_range = $this->num_pages;
}
$this->range = range($this->start_range,$this->end_range);
for($i=1;$i<=$this->num_pages;$i++)
{
if($this->range[0] > 2 And $i == $this->range[0]) $this->return .= " ... ";
if($i==1 Or $i==$this->num_pages Or in_array($i,$this->range))
{
$this->return .= ($i == $this->current_page And $_GET['Page'] != 'All') ? "<a title=\"Go to page $i of $this->num_pages\" class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" title=\"Go to page $i of $this->num_pages\" href=\"".$this->url_next.$i."\">$i</a> ";
}
if($this->range[$this->mid_range-1] < $this->num_pages-1 And $i == $this->range[$this->mid_range-1]) $this->return .= " ... ";
}
$this->return .= (($this->current_page != $this->num_pages And $this->items_total >= 10) And ($_GET['Page'] != 'All')) ? "<a class=\"paginate\" href=\"".$this->url_next.$next_page."\">Next »</a>\n":"<span class=\"inactive\" href=\"#\">» Next</span>\n";
}
else
{
for($i=1;$i<=$this->num_pages;$i++)
{
$this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"".$this->url_next.$i."\">$i</a> ";
}
}
$this->low = ($this->current_page-1) * $this->items_per_page;
$this->high = ($_GET['ipp'] == 'All') ? $this->items_total:($this->current_page * $this->items_per_page)-1;
$this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
}
function display_pages()
{
return $this->return;
}
}
?>
<html>
<head>
<title></title>
</head>
<style type="text/css">
<!--
.paginate {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
}
a.paginate {
border: 1px solid #000080;
padding: 2px 6px 2px 6px;
text-decoration: none;
color: #000080;
}
h2 {
font-size: 12pt;
color: #003366;
}
h2 {
line-height: 1.2em;
letter-spacing:-1px;
margin: 0;
padding: 0;
text-align: left;
}
a.paginate:hover {
background-color: #000080;
color: #FFF;
text-decoration: underline;
}
a.current {
border: 1px solid #000080;
font: bold .7em Arial, Helvetica, sans-serif;
padding: 2px 6px 2px 6px;
cursor: default;
background:#000080;
color: #FFF;
text-decoration: none;
}
span.inactive {
border: 1px solid #999;
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
padding: 2px 6px 2px 6px;
color: #999;
cursor: default;
}
-->
</style>
<body>
<?
include ('config.php');
$strSQL = "SELECT * FROM member WHERE status LIKE '%user%' ORDER BY id ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 5; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" LIMIT $Page_Start, $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="305" border="0" bgcolor="#FFFFFF">
<tr>
<th width="190" bgcolor="#0099FF"> <div align="center">ชื่อผู้ใช้งาน </div></th>
<th width="105" bgcolor="#0099FF"> <div align="center">สถานะ</div></th>
<th width="100" bgcolor="#0099FF"> <div align="center">เปลี่ยนแปลง</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery)) //วนลูปเพื่อแสดงข้อมูลจนครบทุก โดยเก็บข้อมูลไว้ในตัวแปร $objResult ซึ่งเป็นตัวแปรอะเรย์
{
?>
<tr>
<td bgcolor="#99CCFF"><div align="center" >
<?=trim($objResult["name"]);?>
</div></td>
<td bgcolor="#99CCFF"><div align="center" >
<? if($objResult["status"]=="admin")
{
echo "<font color='green'>Admin</font>";
}elseif($objResult["status"]=="user")
{
echo "<font color='red'>User</font>";
};
?>
</div></td>
<td width="30" bgcolor=""><div align="center" >
<a href="UserEditStatus.php?UserID=<?php echo $objResult['id']?>"><img src="images/editP.gif" width="15" height="15" /></a></div></td>
</tr>
<?
}
?>
</table>
<br>
จำนวนผู้ใช้งานระบบทั้งหมด :
<?= $Num_Rows;?>
หน้า :
<?
$pages = new Paginator;
$pages->items_total = $Num_Rows;
$pages->mid_range = 10;
$pages->current_page = $Page;
$pages->default_ipp = $Per_Page;
$pages->url_next = $_SERVER["PHP_SELF"]."?QueryString=value&Page=";
$pages->paginate();
echo $pages->display_pages()
?></td>
</tr>
</table></td>
</tr>
<?php } ?>
<table class="table" width="100%" height="150" border="0" >
<tr>
<td width="33%" valign="top" colspan="3"></td>
</tr>
</table>
<div class="cleared"></div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="art-Post"></div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="art-Footer">
<div class="art-Footer-inner"><a href="#" class="art-rss-tag-icon" title="RSS"></a>
<div class="art-Footer-text"></div>
</div>
<div class="art-Footer-background"></div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="cleared"></div>
</div>
</body>
</html>
ส่วนโค้ดการ แก้ไข เปลี่ยนชื่อ User คับ editprofile.php
Code (PHP)
<?php
session_start();
if(isset($_POST['submit']))
{
include 'config.php';
mysql_query('SET NAMES UTF8');
$sql = "UPDATE member SET name = '".$_POST['txtname']."',
username = '".$_POST['txtusername']."',
password = '".md5($_POST['txtpassword'])."'
WHERE id = '".$_GET["UserID"]."' ";
echo $sql;
if($_POST["txtpassword"] != $_POST["txtConpassword"])
{
echo '<script>alert("รหัสผ่านไม่ตรงกัน \"กรุณากรอกข้อมูลใหม่อีกครั้ง\"");location.href= "editprofile.php"; </script>';
exit();
}
if(mysql_query($sql))
{
echo '<script>alert("เปลี่ยนแปลงการแก้ไขเรียบร้อย"); location.href= "Login.php?logout"; </script>';
}
else
{
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<!--
Created by Artisteer v2.3.0.25189
Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"
-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function validate()
{
if(document.getElementsByName('txtname').item(0).value =='')
{
alert('กรุณาตั้งชื่อเพื่อใช้ในการเข้าระบบ');
return false;
}
if(document.getElementsByName('txtusername').item(0).value =='')
{
alert('กรุณากรอกชื่อในการเข้าระบบ');
return false;
}
if(document.getElementsByName('txtpassword').item(0).value =='')
{
alert('กรุณากรอกรหัสผ่านในการเข้าระบบ');
return false;
}
if(document.editprofile.txtpassword.value.length < 4 || document.editprofile.txtpassword.value.length > 10)
{
alert('กรุณาใส่รหัสผ่านอย่างน้อย 4-10 ตัวอักษร : \"ช่องรหัสผ่านในการเข้าระบบ\"');
return false;
}
if(document.getElementsByName('txtConpassword').item(0).value =='')
{
alert('กรุณากรอกยืนยันรหัสผ่านอีกครั้ง');
return false;
}
if(document.editprofile.rdoAdmin.checked == false && document.editprofile.rdoUser.checked == false )
{
alert('กรุณาเลือกสถานะการใช้งาน');
return false;
}
}
</script>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>แก้ไขข้อมูลการเข้าใช้ระบบ</title>
<script type="text/javascript" src="script.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->
</head>
<body>
<div id="art-page-background-simple-gradient"> </div>
<div id="art-page-background-glare">
<div id="art-page-background-glare-image"></div>
</div>
<div id="art-main">
<div class="art-Sheet">
<div class="art-Sheet-tl"></div>
<div class="art-Sheet-tr"></div>
<div class="art-Sheet-bl"></div>
<div class="art-Sheet-br"></div>
<div class="art-Sheet-tc"></div>
<div class="art-Sheet-bc"></div>
<div class="art-Sheet-cl"></div>
<div class="art-Sheet-cr"></div>
<div class="art-Sheet-cc"></div>
<div class="art-Sheet-body">
<div class="art-Header">
<div class="art-Header-png"></div>
<div class="art-Header-jpeg"></div>
<div class="art-Logo">
<h1 id="name-text" class="art-Logo-name"><a href="#">Inventory management.</a></h1>
<div id="slogan-text" class="art-Logo-text"></div>
</div>
</div>
<div class="art-nav">
<div class="l"></div>
<div class="r"></div>
</div>
<div class="art-contentLayout">
<div class="art-content">
<div class="art-Post">
<div class="art-Post-tl"></div>
<div class="art-Post-tr"></div>
<div class="art-Post-bl"></div>
<div class="art-Post-br"></div>
<div class="art-Post-tc"></div>
<div class="art-Post-bc"></div>
<div class="art-Post-cl"></div>
<div class="art-Post-cr"></div>
<div class="art-Post-cc"></div>
<div class="art-Post-body">
<div class="art-Post-inner">
<div class="art-PostContent">
<h2 class="art-PostHeader"> แก้ไขข้อมูลการเข้าใช้งานระบบ <br>
</h2>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax() {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'checkEditProfile.php';
var pmeters = "check_nameuser_edit=" + encodeURI(document.getElementById("txtname").value);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "...";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'AjaxPHPRegister3.php';
}
else
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjaxEditUserName() {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'checkUserNameEdit.php';
var pmeters = "check_username_edit=" + encodeURI(document.getElementById("txtusername").value);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "...";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'AjaxPHPRegister3.php';
}
else
{
document.getElementById("mySpan1").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
<form action="editprofile.php?UserID=<?=$_GET["UserID"];?>" method="POST" onSubmit="return validate()" name="editprofile">
<?php
include 'config.php';
$strSQL = "SELECT * FROM member WHERE id = '".$_GET["UserID"]."' ORDER BY id ASC";
$query = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($query);
if(!$objResult)
{
echo " Not found id = ".$_GET["UserID"];
}
else{
?>
<table border="0" align="center">
<td><img src="images/editprofile.jpg" width="300" height="300" /></td>
<td><table border="0">
<tr>
<td>ชื่อผู้ใช้งานระบบเดิม :</td>
<td><label>
<?= $_SESSION['name'] ?>
</label></td>
</tr>
<tr>
<tr>
<td>ชื่อผู้ใช้งานระบบใหม่ :</td>
<td><input type="text" name="txtname" id="txtname" OnChange="JavaScript:doCallAjax();"/></td>
<td width="179"> <span id="mySpan"></span></td>
</tr>
<tr>
<td>ชื่อในการเข้าระบบ :</td>
<td><input type="text" name="txtusername" id="txtusername" OnChange="JavaScript:doCallAjaxEditUserName();"/></td>
<td width="179"> <span id="mySpan1"></span></td>
</tr>
<tr>
<td>รหัสผ่านในการเข้าระบบ :</td>
<td><input type="password" name="txtpassword"/></td>
<td>ใส่รหัสผ่านอย่างน้อย 4 ตัวขึ้นไป</td>
</tr>
<tr>
<td>ยืนยันรหัสผ่านอีกครั้ง :</td>
<td><input type="password" name="txtConpassword" id="txtConpassword"/></td>
</tr>
<tr>
<td>สถานะการใช้งาน </td>
<td><input name="status_user" type="radio" value="admin" id="rdoAdmin" />
: Admin </td>
</tr>
<tr>
<td></td>
<td><input name="status_user" type="radio" value="user" id="rdoUser" />
: User</td>
</tr>
<tr>
<td align="center"></td>
<td><table>
<tr>
<td><input type="submit" name="submit" value="ยืนยันการแก้ไข" /></td>
<td><input type="reset" value="ยกเลิก" /></td>
</tr>
</table>
</tr>
<tr>
<td colspan="2" align="center"><a href="Login.php">กลับไปหน้าเข้าสู่ระบบ</a></td>
</tr>
</table>
</table>
<?
}
mysql_close($query);
?>
</form>
<table class="table" width="100%">
<tr>
<td width="33%" valign="top"></td>
<td width="33%" valign="top"></td>
<td width="33%" valign="top"></td>
</tr>
</table>
</div>
<div class="cleared"></div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="art-Post"> </div>
</div>
<div class="cleared"></div>
</div>
<div class="art-Footer">
<div class="art-Footer-inner"> <a href="#" class="art-rss-tag-icon" title="RSS"></a>
<div class="art-Footer-text"> </div>
</div>
<div class="art-Footer-background"></div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="cleared"></div>
</div>
</body>
</html>
มัน Error ไม่ยอมส่งค่า ID มาให้ในหน้าของ editprofile.php คับ
Tag : PHP, JavaScript
|
|
|
|
|
|
Date :
2012-04-18 20:58:22 |
By :
golf |
View :
1380 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id มันถูกเก็บไว้ใน session ไม่ใช่หรอครับ จะเก็บมาจาก $_POST, $_GET มันคงไม่มีค่ามาหรอกนะ ดูใหม่ๆ
|
|
|
|
|
Date :
2012-04-18 23:27:14 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำได้เเล้วคับ .....
|
|
|
|
|
Date :
2012-04-22 22:15:13 |
By :
asus40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|