วันเสาร์ที่ 5 กันยายน พ.ศ. 2558

การเปลี่ยนรหัสผ่าน

<?php

mysql_query("update student set password='$_POST[password]'
where id='{$_SESSION['student']['id']}'");
alert_text('เปลี่ยนรหัสผ่านใหม่เรียบร้อยแล้ว');
redirect("index.php");


?><script  language="javaScript">
function check(){
if(document.form1.newpassword.value ==""){
 alert("กรุณาระบุรหัสผ่านใหม่");
 document.form1.newpassword.focus();
 return false;
 }

  else if (document.form1.repassword.value != document.form1.newpassword.value){
  alert("รหัสผ่านไม่ตรงกัน");
  document.form1.repassword.focus();
  return false;
  }else{return true;}
}
</script>
<table width="100%" height="255"  border="0">
  <tr>
    <td valign="top"><div align="center"><h1>เปลี่ยนรหัสผ่านใหม่</h1>
<form action="" method="post" name="form1" id="form1" onsubmit="return check()">
  <table width="343" border="0" align="center">
 
    <tr>
      <td width="127"><div align="right">รหัสใหม่</div></td>
      <td width="206"><input type="password" name="newpassword" id="s" maxlength="20" /></td>
    </tr>
    <tr>
      <td><div align="right">ยืนยันรหัสอีกครั้ง</div></td>
      <td><input type="password" name="repassword" id="s"  maxlength="20"/></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" id="button" value="ตกลง" />
      <input type="reset" name="button2" id="button2" value="ยกเลิก" /></td>
    </tr>
  </table>
</form>
</div></td>
  </tr>
</table>

logout

<?php
require_once('connect.php');
unset($_SESSION['student']);
unset($_SESSION['login']);
redirect('index.php');
exit();

?>

function checkUser()

function checkUser()
{
// if the session id is not set, redirect to login page
if (!isset($_SESSION['login'])) {
redirect("index.php");
exit();
}

}

วันเสาร์ที่ 29 สิงหาคม พ.ศ. 2558

บันทึกข้อมูลลงฐานข้อมูล

<?php
$id =$_POST[id];
$password        =$_POST[password];
$title =$_POST[title];
$name =$_POST[name];

$sql ="select * from member where id='$id' ";
$result=mysql_query($sql) or die(mysql_error());
$num=mysql_num_rows($result);

if($num > 0)
{
die("<script>
alert('รหัสประจำตัวซ้ำ');
history.back();
</script>");
}

$sql ="insert into member(id,password,title,name,profilepic)
values('$id','$password','$title','$name','$filename')";
$result=mysql_query($sql) or die(mysql_error());
redirect('index.php')
?>

วันพฤหัสบดีที่ 20 สิงหาคม พ.ศ. 2558

SQL Create table

CREATE TABLE `student` (
  `id` varchar(5) NOT NULL,
  `password` varchar(20) NOT NULL,
  `title` varchar(10) NOT NULL,
  `name` varchar(50) NOT NULL,
  `surname` varchar(50) NOT NULL,
  `birthdate` date NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='เก็บข้อมูลนักเรียน';

--
-- dump ตาราง `student`
--

INSERT INTO `student` VALUES ('33333', '333', 'sss', 'wrwwr', 'rrw', '2015-08-19');

วันอาทิตย์ที่ 26 กรกฎาคม พ.ศ. 2558

แปลงวันที่ php

function ThaiDateLong($date) {  
$_month_name = array("01"=>"มกราคม","02"=>"กุมภาพันธ์",
"03"=>"มีนาคม","04"=>"เมษายน","05"=>"พฤษภาคม",
"06"=>"มิถุนายน","07"=>"กรกฏาคม","08"=>"สิงหาคม",
"09"=>"กันยายน","10"=>"ตุลาคม","11"=>"พฤศจิกายน",
"12"=>"ธันวาคม");
$yy=substr($date,0,4);$mm=substr($date,5,2);$dd=substr($date,8,2);$time=substr($date,11,8);
$yy+=543;
// $dateT=intval($dd)." ".$_month_name[$mm]." ".$yy." ".$time;
$dateT=intval($dd)." ".$_month_name[$mm]." พ.ศ. ".$yy;
  return $dateT;
}     //echo ThaiEachDate("2008-05-19");

function ThaiDate($date){
$_month_name = array("01"=>"ม.ค.","02"=>"ก.พ.","03"=>"มี.ค.","04"=>"เม.ย.","05"=>"พ.ค.","06"=>"มิ.ย.","07"=>"ก.ค.","08"=>"ส.ค.","09"=>"ก.ย.","10"=>"ต.ค.","11"=>"พ.ย.","12"=>"ธ.ค.");
$yy=substr($date,0,4);$mm=substr($date,5,2);$dd=substr($date,8,2);$time=substr($date,11,8);
$yy+=543;
$dateT=intval($dd)." ".$_month_name[$mm]." ".$yy." ".$time;
// $dateT=intval($dd)." ".$_month_name[$mm]." ".$yy;
return $dateT;
}

วันเสาร์ที่ 25 กรกฎาคม พ.ศ. 2558

function redirect 'n alert

function redirect($url){
echo "<script type=\"text/javascript\">window.location='".$url."'</script>";
}

function alert_text($msg){
echo "<script type=\"text/javascript\">alert('$msg') </script>";
}

Login PHP

$username = $_POST[username];
$password = $_POST[password];
$sql="select * from personal where id='$username' and password='$password'";
$result=mysql_query($sql) or die(mysql_error());
$num=mysql_num_rows($result);

if($num == 0)
{
die("<script>
alert('รหัสประจำตัวหรือรหัสผ่านไม่ถูกต้อง');
history.back();
</script>");
}
$_SESSION['login'] = true;
$_SESSION['personal'] = mysql_fetch_assoc($result);
session_write_close();
redirect('index.php');
exit();

วันศุกร์ที่ 26 มิถุนายน พ.ศ. 2558

หลักสูตรอบรม ม.1 ม.4 ปี 2558 ภาคเรียนที่ 1

หลักสูตร ม.1 (10 บทความ)
1.หลักการทำงานของคอมพิวเตอร์
2.บทบาทของคอมพิวเตอร์
3.ประโยชน์ของคอมพิวเตอร์
4.ความสำคัญของเทคโนโลยี
5.ผลกระทบของเทคโนโลยี
6.ความหมายของข้อมูลและสารสนเทศ
7.ประเภทของข้อมูล
8.วิธีการประมวลผลของข้อมูล
9.การจัดการสารสนเทศ
10.ระดับของสารสนเทศ
หลักสูตรม.4 (10 บทความ)
1. ความหมายของเทคโนโลยี
2. ความสำคัญและบทบาทของเทคโนโลยี
3. ความสัมพันธ์ระหว่างเทคโนโลยีกับศาสตร์อื่นๆ
4. กระบวนการเทคโนโลยี
5. การออกแบบ
6. ตัวอย่างการออกแบบ
7. 5W1H
8. เทคโนโลยีสะอาด
9. ซฮฟแวร์ที่ใช้ในงานออกแบบ (2 มิติ)
10. ซฮฟแวร์ที่ใช้ในงานออกแบบ (3 มิติ)

เนื้อหา
1. การใช้อีเมล @srp.ac.th srpรหัส@srp.ac.th ,google drive
2. classroom
3. สร้าง blog หัวข้อ ชื่อ-สกุล ชื่อ blog srpเลขประจำตัว
4. หน้าประวัติ ทำเป็นหน้าเวบเมนู ค่านิยม 12 ประการ ใส่พฤติกรรมตัวเองในแต่ละข้อ
5. แจ้งลิ้งค์ในไฟล์Excel
6. เพิ่มบทความ
7. ใส่ Gadget

วันพุธที่ 14 มกราคม พ.ศ. 2558

วันพฤหัสบดีที่ 12 มิถุนายน พ.ศ. 2557

แจ้ง Url เว็บบล็อก ม.5/8 ปี 2557

แจ้งชื่อบล๊อก ชื่อนามสกุล เลขที่ รหัสประจำตัว

แจ้ง Url เว็บบล็อก ม.5/6 ปี 2557

แจ้งชื่อบล๊อก ชื่อนามสกุล เลขที่ รหัสประจำตัว

แจ้ง Url เว็บบล็อก ม.5/1 ปี 2557

แจ้งชื่อบล๊อก ชื่อนามสกุล เลขที่ รหัสประจำตัว

วันพุธที่ 11 มิถุนายน พ.ศ. 2557

แจ้ง Url เว็บบล็อก ม.5/7 ปี 2557

แจ้งชื่อบล๊อก ชื่อนามสกุล เลขที่ รหัสประจำตัว