|
|
|
อยากทราบว่าสคิปอัปรูปตัวนี้มันผิดตรงไหน ครับไมมันdenied ตลอดเลย |
|
|
|
|
|
|
|
Code (PHP)
<?
include("../lib/utility.php");
connect_db();
$pic_size = $_FILES["pic"]["size"];
$pic_type = $_FILES["pic"]["type"];
$pic_tmp = $_FILES["pic"]["tmp_name"];
// Check Pre Input
if (!isset($_REQUEST["username"])
|| !isset($_REQUEST["password"])
|| !isset($_REQUEST["confirm"])
|| !isset($_REQUEST["name"])
|| !isset($_REQUEST["surname"])
|| !isset($_REQUEST["email"])
|| !isset($_REQUEST["gender"])
|| !isset($_REQUEST["address"])
|| !isset($_REQUEST["country"])
|| !isset($_REQUEST["day"])
|| !isset($_REQUEST["month"])
|| !isset($_REQUEST["year"])) {
header("location:register_form.php");
return;
}
// Prepare Variables
$username = $_REQUEST["username"];
$password = sha1($_REQUEST["password"]);
$confirm = sha1($_REQUEST["confirm"]);
$name = $_REQUEST["name"];
$surname = $_REQUEST["surname"];
$email = $_REQUEST["email"];
$gender = $_REQUEST["gender"];
$address = nl2br($_REQUEST["address"]);
$country = $_REQUEST["country"];
$bday = $_REQUEST["day"];
$bmonth = $_REQUEST["month"];
$byear = $_REQUEST["year"];
$birthday = "$byear-$bmonth-$bday";
if (isset($_REQUEST["interest"])) {
$interest = implode(", ", $_REQUEST["interest"]);
}
else {
$interest = "";
}
$code = random_password();
// Check Post Input
$error = "";
// Username 1
if ($username == "") {
$error .= "ไม่มีชื่อผู้ใช้<br />";
}
// Picture
if ($pic_size == 0) {
$error .= "ไม่มีรูปภาพ<br />";
}
else {
if ($pic_size > 1024*100) {
$error .= "ขนาดไฟล์รูปภาพเกินกว่า 100 kb<br />";
}
if ($pic_type != "image/pjpeg" && $pic_type != "image/jpeg" && $pic_type != "image/gif") {
$error .= "ชนิดไฟล์รูปภาพไม่ใช่ jpeg และ gif<br />";
}
}
// Username 2
$sql = "SELECT COUNT(*) FROM member WHERE username='$username'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$num_user = $row["COUNT(*)"];
if ($num_user != 0) {
$error .= "ชื่อผู้ใช้ซ้ำ<br />";
}
// Password
if ($password != $confirm) {
$error .= "ยืนยันรหัสผ่านไม่ตรงกับรหัสผ่าน<br />";
}
// E-mail 1
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
$error .= "รูปแบบอีเมลผิด<br />";
}
// E-mail 2
$sql = "SELECT COUNT(*) FROM member WHERE email='$email'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$num_user = $row["COUNT(*)"];
if ($num_user != 0) {
$error .= "อีเมลซ้ำ<br />";
}
// Birthday
if (!checkdate($bmonth, $bday, $byear)) {
$error .= "วันเกิดไม่มีอยู่จริง<br />";
}
// Action
if ($error == "") {
// Add New Member
$sql = "INSERT INTO member"
. " (username, password, name, surname, email, gender, address, country, birthday, interest, code, `create`)"
. " VALUES('$username', '$password', '$name', '$surname', '$email', '$gender', '$address', '$country', '$birthday', '$interest', '$code', CURDATE())";
mysql_query($sql) or die(mysql_error());
$id = mysql_insert_id();
move_uploaded_file($pic_tmp, "../shop/images/$id.jpg");
// Send E-mail
send_mail("webmaster@fffff",
$email,
"New Account from ddd.net",
"ท่านได้เข้าสู่การเปิดใช้บัญชีใหม่จาก ffff.net<br />กดยืนยันเพื่อเปิดบัญชี <a href='http://ffff.net/dshome/html/member/activate.php?username=$username&code=$code' target='_blank'>here</a> ________ขอขอบพระคุณที่ใช้บริการ.");
// Delete Unactivated Account
$sql = "DELETE FROM member WHERE code<>'' AND DATEDIFF(CURDATE(), `create`) > 3";
mysql_query($sql) or die(mysql_error());
}
// Show Result
if ($error == "") {
$result = "ลงทะเบียนผู้เรียนคนใหม่เรียบร้อย<br />"
. "<a href='login_form.php'>ลงชื่อเข้าใช้</a>";
}
else {
$result = $error
. "<a href='#' onclick='history.back(); return false;'>กลับไป</a>";
}
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ระบบสมาชิก - ลงทะเบียนผู้ใช้</title>
<style type="text/css">
<!--
body,td,th {
color: #FFF;
}
body {
background-color: #000;
}
-->
</style></head>
<body>
<?=$result?>
</body>
</html>
output
ไม่มีรูปภาพ
กลับไป
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2012-12-13 16:04:18
|
|
|
|
|
Date :
2012-12-13 15:51:18 |
By :
shiowa |
View :
875 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ เติม enctype="multipart/form-data" ตรง form ได้เลย ขอขอบคุณพี่วินและ prakrim
|
|
|
|
|
Date :
2012-12-13 16:27:26 |
By :
shiowa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2012-12-14 09:24:30 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|