|
 |
|
ขอผู้รู้ช่วยหน่อยได้มั้ยครับ ด่วนมาก !!!!!!!!!!!!!!!!!!!!!!!!!! |
|
 |
|
|
 |
 |
|
ดูโค้ดตัวนี้ให้หน่อยครับเวลาเข้าเคส $_REQUEST["avatar"] แล้วมันไม่บันทึกข้อมูลอะครับ
Code (PHP)
<?
function show_msg($msg)
{
echo'<script language="Javascript">';
echo"alert('".$msg."')";
echo'</script>';
}
if($_REQUEST["btnSubmit"]) {
if($_POST["code"] != $_SESSION["security_number"]) {
unset( $_SESSION['security_number']);
echo "<script type=\"text/javascript\">alert(\"ป้อนผลลัพธ์ไม่ถูกต้อง\");history.back();</script>";
exit();
}
if(!empty($_FILES["uppic"])) {
$ints = date('YmdGis');
if($_FILES["uppic"]["type"]=="image/png")
$img = "js".$ints.".png";
if($_FILES["uppic"]["type"]=="image/gif")
$img = "js".$ints.".gif";
elseif($_FILES["uppic"]["type"]=="image/pjpeg"||$_FILES["uppic"]["type"]=="image/jpeg")
$img = "js".$ints.".jpg";
}else{
echo "
<script type=\"text/javascript\">
alert(\"ไม่ใช่ไฟล์ jpg/png/gif โปรดแก้ไข\");history.back(-1);
</script>
";
exit();
}
if($_REQUEST["avatar"]){
$newname = $_REQUEST["avatar"];
}
if($img!=""){
$folderpic = "../register/uploads" ; //ชื่อโฟลเดอร์ที่ไว้ใช้เก็บไฟล์
$max_size = 500; // จำกัดขนาดไฟล์ ค่าเป็น kb
$width=100; //ขนาดความกว้างที่ต้องการ Resize
$height=100; // ขนาดความสูงที่ต้องการ Resize
$file_size=$_FILES['uppic']['size']; // ตัวแปรขนาดของไฟล์
$limit_size=1000*$max_size;
if($file_size >= $limit_size){
echo "<script language='javascript'>alert('ไฟล์ของคุณใหญ่เกินไปครับต้องมีขนาดไม่เกิน $max_size kb');</script>";
} else {
if($_FILES["uppic"]["tmp_name"]){
$fileUpload=$_FILES["uppic"]["tmp_name"]; // ตัวแปร temp
$fileUpload_name=$_FILES["uppic"]["name"]; // ตัวแปรชื่อไฟล์
if (isset($_FILES[uppic][name])) { // ถ้ามีการเซทชื่อไฟล์มาให้ประมวลผลส่วนนี้
//*** ส่วนนี้คือการ Rename รูปให้เป็นวันที่ที่บันทึก ***//
$ext = strtolower(end(explode('.', $fileUpload_name)));
$dateUpFile=date("YmdHis");
$newname="js".$dateUpFile.".".$ext; //ชื่อไฟล์ที่กำหนดขึ้นมาใหม่ โดยใช้วันและเวลาเป็นตัวกำหนดตั้งชื่อ
//*** สร้างภาพขึ้นมาใหม่ตามนามสกุลของไฟล์เดิม ***//
$images = $fileUpload;
$size = getimagesize($images);
$img_type=strtolower(end(explode('.',$images)));
if($size[2] == 1) {
$images_orig = imagecreatefromgif($images); // GIF
} else if($size[2] == 2) {
$images_orig = imagecreatefromjpeg($images); // JPEG
}
else if($size[2] == 3) {
$images_orig = imagecreatefrompng($images); // png
}
//*** ส่วนนี้คือการ Resize รูป ***//
$photoX = imagesx($images_orig);
$photoY = imagesy($images_orig);
$images_fin = imagecreatetruecolor($width, $height);
imagecopyresampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY); // ทำการ Resize ภาพ
imagegif($images_fin,"$folderpic/".$newname);
imagedestroy($images_orig);
imagedestroy($images_fin);
}
}
}
$_SESSION["name"]= $_REQUEST['name'];
$_SESSION["surname"]= $_REQUEST['surname'];
$_SESSION["email"]= $_REQUEST['email'];
$_SESSION["age"]= $_REQUEST['age'];
$_SESSION["phone"]= $_REQUEST['phone'];
$_SESSION["school"]= $_REQUEST['school'];
$_SESSION["class"]= $_REQUEST['class'];
$_SESSION["pass"]=$_REQUEST['pass'];
$sql1="SELECT count(email) as xemail FROM `register` WHERE email ='".$_SESSION["email"]."' ";
$rows=mysql_query($sql1) or die(mysql_error());
$result=mysql_fetch_assoc($rows);
if($result["xemail"]>=1){
echo '<script type="text/javascript">alert("Email นี้ มีผู้ใช้แล้ว กรุณากรอกEmail ใหม่ค่ะ");history.back(-1);</script>';
exit();
}
$sql="INSERT INTO register(name,surname,email,age,phone,school,class,password,picture,date) VALUES('".$_SESSION["name"]."','".$_SESSION["surname"]."','".$_SESSION["email"]."','".$_SESSION["age"]."','".$_SESSION["phone"]."','".$_SESSION["school"]."','".$_SESSION["class"]."','".$_SESSION["pass"]."','$newname',NOW())";
mysql_query($sql) or die(mysql_error());
}
show_msg("ท่านได้ทำการลงทะเบียนเรียบร้อยแล้ว");
}else{
show_msg("ผิดพลาด กรุณาทำรายการใหม่อีกครั้ง!!");
}
?>
Tag : PHP

|
ประวัติการแก้ไข 2012-08-25 13:37:25 2012-08-25 15:03:28
|
 |
 |
 |
 |
Date :
2012-08-25 13:15:17 |
By :
l3alLkisS |
View :
1202 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค้าบบบบ
|
ประวัติการแก้ไข 2012-08-25 16:43:44
 |
 |
 |
 |
Date :
2012-08-25 13:16:41 |
By :
l3alLkisS |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอดีรีบไปหน่อย แก้ได้แล้วครับ เพราะใส่ปีกกาผิดที่
|
 |
 |
 |
 |
Date :
2012-08-25 16:43:03 |
By :
l3alLkisS |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|