Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web
Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web Diễn đàn thiết kế web, thiết kế web, thiết kế website, thiet ke web, thiet ke website, tìm hiểu web

Quay lại   Dien dan thiet ke web > Lập trình (code) > Thiết kế lập trình .PHP

Thiết kế lập trình .PHP Các vấn đề liên quan .PHP


Gửi trả lời
 
LinkBack Công Cụ Dạng sắp xếp bài
  #1 (permalink)  
Cũ 08-20-2009, 04:47 PM
klb klb đang Offline
Senior Member
 
Ngày gia nhập: Aug 2009
Bài gửi: 676
Mặc định Tạo file register.php

Tạo file register.php

Code:
<!----search Internet---!>

<?
session_start();
include("database.php");


function usernameTaken($username){
global $conn;
if(!get_magic_quotes_gpc()){
$username = addslashes($username);
}
$q = "select username from users where username = '$username'";
$result = mysql_query($q,$conn);
return (mysql_numrows($result) > 0);
}


function addNewUser($username, $password){
global $conn;
$q = "INSERT INTO users VALUES ('$username', '$password')";
return mysql_query($q,$conn);
}


function displayStatus(){
$uname = $_SESSION['reguname'];
if($_SESSION['regresult']){
?>

<h1>Registered!</h1>
<p>Thank you <b><? echo $uname; ?></b>, your information has been added to the database, you may now <a href="main.php" title="Login">log in</a>.</p>

<?
}
else{
?>

<h1>Registration Failed</h1>
<p>We're sorry, but an error has occurred and your registration for the username <b><? echo $uname; ?></b>, could not be completed.
Please try again at a later time.</p>

<?
}
unset($_SESSION['reguname']);
unset($_SESSION['registered']);
unset($_SESSION['regresult']);
}

if(isset($_SESSION['registered'])){

?>

<html>
<title>Registration Page</title>
<body>

<? displayStatus(); ?>

</body>
</html>

<?
return;
}


if(isset($_POST['subjoin'])){

if(!$_POST['user'] || !$_POST['pass']){
die('You didn\'t fill in a required field.');
}


$_POST['user'] = trim($_POST['user']);
if(strlen($_POST['user']) > 30){
die("Sorry, the username is longer than 30 characters, please shorten it.");
}


if(usernameTaken($_POST['user'])){
$use = $_POST['user'];
die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one.");
}


$md5pass = md5($_POST['pass']);
$_SESSION['reguname'] = $_POST['user'];
$_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass);
$_SESSION['registered'] = true;
echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[PHP_SELF]\">";
return;
}
else{

?>

<html>
<title>Registration Page</title>
<body>
<h1>Register</h1>
<form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr>
</table>
</form>
</body>
</html>


<?
}
?>
 Nuoc hoaMy phamTrang diemLam depQua tang
Trả lời kèm theo trích dẫn

10 Chủ đề mới nhất của klb
Chủ đề Chuyên mục Người gởi sau cùng Trả lời Lần đọc Bài mới gửi
Foxit Phantom: Thay thế đáng giá cho Foxit Reader Mạng CISCO klb 0 186 02-03-2010 12:00 AM
Template Monster Design Studio p3 Web Templates khác klb 0 218 02-02-2010 11:39 PM
Template Monster Design Studio p2 Web Templates khác klb 0 159 02-02-2010 11:39 PM
Template Monster Design Studio Web Templates khác klb 0 157 02-02-2010 11:37 PM
20 Flash Menu Templates Flash klb 0 314 02-02-2010 11:36 PM
DesignLoad Premium Flash Intros Templates Flash klb 0 162 02-02-2010 11:29 PM
Flash CS4 - Bài 14: Sử dụng Color effect Flash klb 0 129 02-02-2010 11:27 PM
Xem 2.780 kênh TV từ toolbar của Firefox Các vấn đề khác liên quan đến Mạng klb 0 112 02-02-2010 11:24 PM
Driver Easy: tự động nhận dạng và tìm driver cho... Các vấn đề khác liên quan đến Mạng klb 0 108 02-02-2010 11:23 PM
Duyệt ảnh và video theo phong cách 3D với Cooliris Photoshop klb 0 143 02-02-2010 11:21 PM

Gửi trả lời

Công Cụ
Dạng sắp xếp bài

Quyền hạn Gửi bài
Bạn không thể gửi chủ đề
Bạn không thể gửi trả lời
Bạn không thể gửi đính kèm
Bạn không thể sửa bài của mình

Mã BB đang Mở
[IMG] đang Mở
Mã HTML đang Tắt
Trackbacks are Mở
Pingbacks are Mở
Refbacks are Mở


Viec Lam - Việc làm - Tuyen Dung - Tuyển Dụng - Tìm Việc Làm và Đăng Tuyển Dụng Miễn Phí Thiet ke web, Thiết kế web, Thiết kế website đẹp chuyên nghiệp Tổ chức sự kiện, Công ty Truyền thông Thương hiệu Quốc tế, e marketing Hoa tươi, hoa đẹp, Shop hoa, điện hoa, hoa cưới
To chuc su kien VIP - Tổ chức sự kiện - Công ty tổ chức sự kiện Balo , Ba lô, Balo Laptop, Balo tui xach, balo cap hoc sinh in ky thuat so, ke x, kệ x, standy, standee, rollup banner, banner stand dong phuc the thao, do bong da, quan ao bong ro, dong phuc lop

Tất cả thời gian được tính theo GMT +7. Bây giờ là 01:02 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.