* Login   * Register


Last visit was:
It is currently Sat Feb 24, 2018 2:57 pm
View unanswered posts
View active topics





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Mor so code xu li
PostPosted: Sun May 31, 2009 8:18 pm 
Offline

Joined: Thu Feb 05, 2009 7:16 pm
Posts: 9
1.Hiển thị thời gian hệ thống
<script type="text/javascript">
var mydate=new Date()
var year=mydate.getYear()
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
var phut=mydate.getMinutes()
var gio=mydate.getHours()
var giay=mydate.getSeconds()
if (daym<10)daym="0"+daym
var dayarray=new Array("Chủ nhật","Thứ hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ bảy")var montharray=new Array("/ 01","/ 02","/ 03","/ 04","/ 05","/ 06","/ 07","/ 08","/ 09","/ 10","/ 11","/12")document.write("<strong > Today_" +dayarray[day]+"_Ngày "+daym+" "+montharray[month]+" / "+year+"</strong>" )
</script>
2.Kiểm tra thông tin đăng nhập
<script type="text/javascript">
function checkinput()
{
if(document.submit.email.value=="")
{
alert("vui lòng nhập địa chi email của bạn.");
document.submit.email.focus();
return false;
}
if(document.submit.username.value=="")
{
alert("vui lòng nhập tên đăng nhập của bạn.");
document.submit.username.focus();
return false;
}
if(document.submit.password.value=="")
{
alert("vui lòng nhập mật khẩu của bạn.");
document.submit.password.focus();
return false;
}
return true;
}
</script>
3. Đăng kí thành viên
<?php
$conn=mysql_connect("localhost","root","")or die("chit");
mysql_select_db("mysqlserver",$conn);
$email=$_POST["email"];
$username=$_POST["username"];
$password=$_POST["password"];
$name=$_POST["name"];
$lastname=$_POST["lastname"];
$birthday=$_POST["birthday"];
$job=$_POST["job"];
$company=$_POST["company"];
$address=$_POST["address"];
$city=$_POST["city"];
$country=$_POST["country"];
$gender=$_POST["gender"];
$sql="select*from admin where email='$email' and username='$username'";
$kq=mysql_query($sql,$conn);
if(mysql_num_rows($kq)!=0)
{
echo"email nay da ton tai";
}
else
{
$sql="insert into admin(email,username,password,name,lastname,birthday,job,company,address,city,country,gender) value('$email','$username','$password','$name','$lastname','$birthday','$job','$company','$address','$city','$country','$gender')";
$kq=mysql_query($sql,$conn);
include("thanhvien.html");
}
?>
4.Đăng nhập
<html>
<body>
<?php
$conn=mysql_connect("localhost","root","")or die("khong ket noi duoc co so du lieu");
mysql_select_db("mysqlserver",$conn);
$username=$_POST["username"];
$password=$_POST["password"];
$sql="select*from admin where username='$username' and password='$password'";
$kq=mysql_query($sql,$conn);
if(mysql_num_rows($kq)==0)
{
include("thongbao.html");
}
else
{
include("new.html");
}
?>
</body>
</html
5.Tiềm kiếm
<?php
$link=mysql_connect("localhost","root","")or die("Khong ket noi duoc CSDL");
mysql_select_db("mysqlserver",$link)or die("Khong tim thay table nay trong CSDL");
$cachtim=$_POST['txttim'];
$totalRows=0;
$paging="";
if($cachtim=='mainboard')
{
$ten=$_POST["search"];
$kq="SELECT* FROM mainboard WHERE hangsx like '%$ten%'";
$result=mysql_query($kq,$link);
$totalRows=mysql_num_rows($result);
$rows=mysql_num_rows($result);
if($rows==0)
{
echo "Khong Tim Thay!!";
}
else
{
echo "Search by:hang sx";
echo"<br> Tong so mau tintim thay :$totalRows";
echo"<br>";
echo "<table border=1><tr>
<td>Hangsx</td>
<td>Loai</td>
<td>Gia</td>
</tr><br>";
while($array=mysql_fetch_array($result))
{
echo "<tr>
<td><font color='red'>".$array['hangsx']."</font></td>
<td>".$array['loai']."</td>
<td>".$array['giathanh']."</td>
</tr>";
}
echo "</table>";
}
}
?>
6.Tạo guestbook
Tạo file create.php
<?php
include("connectdb.php");
if(isset($_POST['submit'])) {
$name = $_POST['name'] ;
$age = $_POST['age'];
$email = $_POST['email'];
$address = $_POST['address'];
$comments = $_POST['comments'];
$sql= "INSERT INTO guestbook(name, age, email, address, comments)VALUES ('".$name."', '".$age."', '".$email."', '".$address."', '".$comments."')";
mysql_query($sql) or die(mysql_error());
?>
<a href="view.php">View my address book</a>
<?}?>
Tạo file connectdb.php
<?php
$conn=mysql_connect("localhost","root","")or die("khong ket noi duoc co so du lieu");mysql_select_db("mysqlserver",$conn);
?>
Tạo file view.php
<?php include("connectdb.php"); ?>
<h2>View My Address Book!!</h2>
<?php
$result = mysql_query("select * from guestbook") or die (mysql_error());
while ($row = mysql_fetch_array($result))
{
echo "<b>Name:</b>";
echo $row["name"];
echo "<br>\n";
echo "<br>\n";
echo "<b>Age:</b>";
echo $row["age"];
echo "<br>\n";
echo "<br>\n";
echo "<b>Email:</b>";
echo $row["email"];
echo "<br>\n";
echo "<br>\n";
echo "<b>Comments:</b>";
echo $row["comments"];
echo "<br>\n";
echo "<br>\n";
echo "<br>\n";
}
mysql_free_result($result);
?>
<h2><a href="guestbook.html">Sign My Guest Book!!</a></h2>
:ugeek: :geek: :geek: :geek: :geek: :geek: :geek:


Report this post
Top
 Profile E-mail  
Reply with quote  
 Post subject: Re: Mor so code xu li
PostPosted: Mon Jun 01, 2009 3:20 pm 
Offline

Joined: Thu Feb 05, 2009 7:16 pm
Posts: 9
bạn nào có code xử lí xóa, sửa post lên cho mình với :cry: :cry: :cry: :geek: :geek: :geek: :geek: :geek: :geek: thanks


Report this post
Top
 Profile E-mail  
Reply with quote  
 Post subject: Re: Mor so code xu li
PostPosted: Mon Jun 01, 2009 7:40 pm 
Offline

Joined: Tue Feb 10, 2009 5:42 pm
Posts: 10
mình có code sửa nè bạn xem thử có được không nha!
<?PHP
$u=$HTTP_POST_VARS["user"];
$p=$HTTP_POST_VARS["password"];
$pc=$HTTP_POST_VARS["passc"];
$s=$HTTP_POST_VARS["ch"];
$kd=$HTTP_POST_VARS["nch"];
$kn=mysql_connect("localhost","root","");
mysql_select_db("QLNHKSCL",$kn);
$sql="select*from nsd where ten='$u'and password='$p'";
$kq=mysql_query($sql,$kn);


if(mysql_num_rows($kq)==0)
{
echo "Bạn chưa có tài khoản, mời bạn thêm vào đây";
require "them.php";
}
else
{
$sql="update nsd set password='$pc' where ten='$u'";
$kq=mysql_query($sql,$kn);
echo " B&#7841;n &#273;ã thay &#273;&#7893;i password thành công";

mysql_close($kn);
}

?>


Report this post
Top
 Profile E-mail  
Reply with quote  
 Post subject: Re: Mor so code xu li
PostPosted: Mon Jun 01, 2009 7:53 pm 
Offline
User avatar

Joined: Thu Feb 05, 2009 4:19 pm
Posts: 17
Đây là code xử lí thêm, xóa, sửa chung trên một form

Code:
<?php
   require("ketnoi.php");
   $makh=$_POST["txtmakh"];
   $tenkh=$_POST["txttenkh"];
   $mk=$_POST["txtmk"];
   $phai=$_POST["txtphai"];
   $dc=$_POST["txtdc"];
   $dt=$_POST["txtdt"];
   $email=$_POST["txtemail"];
   $them=$_POST["them"];
   $xoa=$_POST["xoa"];
   $sua=$_POST["sua"];
   if(isset($them))
   {
      $sql="insert into khachhang(MaKhachHang,TenKhachHang,MatKhau,Phai,DiaChi,DienThoai,Email) value ('$makh','$tenkh','$mk','$phai','$dc','$dt','$email')";
      $kq=mysql_query($sql,$conn);
      
   }
   if(isset($xoa))
   {
      $sql="delete from khachhang where MaKhachHang='$makh'";
      $kq=mysql_query($sql,$conn);   
         
   }
   if(isset($sua))
   {
      $sql="update khachhang set TenKhachHang='$tenkh',MatKhau='$mk',Phai='$phai',DiaChi='$dc',DienThoai='$dt',Email='$email'  where MaKhachHang='$makh'";
      $kq=mysql_query($sql,$conn);
   }
   include("capnhatkhachhang.php");
?>


Report this post
Top
 Profile E-mail  
Reply with quote  
 Post subject: Re: Mor so code xu li
PostPosted: Tue Jun 02, 2009 8:23 pm 
Offline

Joined: Thu Feb 05, 2009 7:16 pm
Posts: 9
---------
thanks bạn Dung, chúc bạn thi thật tốt trong kì thi này hj :geek: :geek: :geek: :geek: :geek: :geek: :geek: :geek: :geek: :geek: :geek: :geek:


Report this post
Top
 Profile E-mail  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Create Forum · php-BB© · Internationalization Project · Report abuse · Terms Of Use/Privacy Policy
© Forums-Free.com 2009