|
|
|
ช่วยดูให้ทีครับได้โปรด มันเก็บข้อมูลได้ โดยไม่ได้ตั้งใจ ทั้ง ๆ ที่เช็ค error แล้ว!!~ |
|
|
|
|
|
|
|
ปัญหามันมีอยู่ว่า แก้มา 2 วันล่ะหมดปัญญา!!~
สมัครสมาชิกกด ตกลงแล้ว มันเช็คว่า Email ไส่ไม่ถูกต้อง ให้ไส่ใหม่ แต่พอ Email ถูกต้องแล้ว Loginame ดัดเก็บข้อมูลลงไปแล้ว ทำให้สมัครสามาชิกชื่อนั้นไม่ได้
จะได้ใส่คำสั่งอะไรครับ ช่วยด้วย!!~
#<?php
include_once("imgresize/hft_image.php");
$CFG['folderphoto'] = "filesupload/";
$CFG['folderthumb'] = "filesupload/thumb/";
$CFG['folderthumbindex'] = "filesupload/thumb_index/";
$CFG['photo_h_index'] = 120;
$CFG['photo_w_index'] = 120;
$CFG['photo_h_album'] = 400;
$CFG['photo_w_album'] = 400;
$CFG['maxsize'] = 204800;
include_once ("connect.php");
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$date=date("d.M.Y");
$logname = clean($_POST['logname']);
$passwd = clean($_POST['passwd']);
$pass1 = clean($_POST['pass1']);
$name = clean($_POST['name']);
$age = clean($_POST['age']);
$address = clean($_POST['address']);
$facebook = clean($_POST['facebook']);
$email = clean($_POST['email']);
$hifive = clean($_POST['hifive']);
$ip = $_SERVER['REMOTE_ADDR'];
if(empty($login))
{
die("<script language='javascript'>alert('กรุณาไส่ LOGIN');history.back();</script>");
exit();
}
if(empty($passwd))
{
die("<script language='javascript'>alert('กรุณาไส่ PASSWORD');history.back();</script>");
exit();
}
if($passwd != $passwd1)
{
die("<script language='javascript'>alert('Confirmpassword กับ Password ไม่ตรงกัน');history.back();</script>");
exit();
}
if ( !ereg("^(.+)@(.+)\\.(.+)$" , $email ) )
{
die ("<script language='javascript'>alert('EMAIL นี้ไม่ถูกต้องตามหลัก!!~');history.back();</script> ");
exit();
}
$strSQL = "SELECT * FROM userinfo WHERE login = '".$_POST["login"]."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<script language='javascript'>alert('$login นี้มีผู้ใช้แล้วค่ะ');history.back();</script> ";
}
else
{
$strSQL = "SELECT * FROM userinfo WHERE email = '".$_POST["email"]."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult){
echo "<script language='javascript'>alert('E-mail นี้มีผู้ใช้แล้วค่ะ');history.back();</script> ";
}
if ($_FILES['picture']['size'] > $CFG['maxsize']) {
echo "รูปมันใหญ่เกินไปแล้ว ไส่ใหม่ต้องไม่เกิน ".$CFG['maxsize']."";
exit();
}
if($_FILES['picture']['size'] < $CFG['maxsize'])
{
$fileType = strstr(strtolower($_FILES['picture']['name']),'.');
if(($fileType==".jpg")||($fileType==".gif")||($filetype==".png"))
{
$rand = rand(00000000000,99999999999999);
$getFileName = $rand.$fileType;
if(move_uploaded_file($_FILES['picture']['tmp_name'],$CFG['folderphoto'].$getFileName)){
chmod($CFG['folderphoto'].$getFileName, 0755);
$img_resize = new hft_image($CFG['folderphoto'].$getFileName);
$img_resize->resize($CFG['photo_w_index'],$CFG['photo_h_index'],"-");
$img_resize->output_resized($CFG['folderthumbindex'].$getFileName);
$img_resize = new hft_image($CFG['folderphoto'].$getFileName);
$img_resize->resize($CFG['photo_w_album'],$CFG['photo_h_album'],"-");
$img_resize->output_resized($CFG['folderthumb'].$getFileName);
}
}
$strSQL = "INSERT INTO userinfo (login,passwd,name,age,sex,picture,crew,email,facebook,hifive,ip,date,time)
VALUES
('$login','$passwd','$name','$age','$sex','$picture','$crew','$email','$facebook','$hifive','$ip','$date','$time')";
$objQuery = mysql_query($strSQL);
if($objQuery){
echo "คุณลงทะเบียนสำเร็จแล้ว ";
header("location:index.php");
}
else{
echo "กรุณาลงทำเบียนใหม่อีกครั้ง";
}
}
}
mysql_close($connect);
?>
#Code
[/code]Code
[code]
Tag : - - - -
|
|
|
|
|
|
Date :
2009-11-09 18:42:25 |
By :
yacoolz |
View :
947 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code
!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>Untitled Document</title>
</head>
<?php
include_once("imgresize/hft_image.php");
$CFG['folderphoto'] = "filesupload/";
$CFG['folderthumb'] = "filesupload/thumb/";
$CFG['folderthumbindex'] = "filesupload/thumb_index/";
$CFG['photo_h_index'] = 120;
$CFG['photo_w_index'] = 120;
$CFG['photo_h_album'] = 400;
$CFG['photo_w_album'] = 400;
$CFG['maxsize'] = 204800;
include_once ("connect.php");
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$date=date("d.M.Y");
$logname = clean($_POST['logname']);
$passwd = clean($_POST['passwd']);
$pass1 = clean($_POST['pass1']);
$name = clean($_POST['name']);
$age = clean($_POST['age']);
$address = clean($_POST['address']);
$facebook = clean($_POST['facebook']);
$email = clean($_POST['email']);
$hifive = clean($_POST['hifive']);
$ip = $_SERVER['REMOTE_ADDR'];
if(empty($login))
{
die("<script language='javascript'>alert('กรุณาไส่ LOGIN');history.back();</script>");
exit();
}
if(empty($passwd))
{
die("<script language='javascript'>alert('กรุณาไส่ PASSWORD');history.back();</script>");
exit();
}
if($passwd != $passwd1)
{
die("<script language='javascript'>alert('Confirmpassword กับ Password ไม่ตรงกัน');history.back();</script>");
exit();
}
if ( !ereg("^(.+)@(.+)\\.(.+)$" , $email ) )
{
die ("<script language='javascript'>alert('EMAIL นี้ไม่ถูกต้องตามหลัก!!~');history.back();</script> ");
exit();
}
$strSQL = "SELECT * FROM userinfo WHERE login = '".$_POST["login"]."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<script language='javascript'>alert('$login นี้มีผู้ใช้แล้วค่ะ');history.back();</script> ";
}
else
{
$strSQL = "SELECT * FROM userinfo WHERE email = '".$_POST["email"]."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult){
echo "<script language='javascript'>alert('E-mail นี้มีผู้ใช้แล้วค่ะ');history.back();</script> ";
}
if ($_FILES['picture']['size'] > $CFG['maxsize']) {
echo "รูปมันใหญ่เกินไปแล้ว ไส่ใหม่ต้องไม่เกิน ".$CFG['maxsize']."";
exit();
}
if($_FILES['picture']['size'] < $CFG['maxsize'])
{
$fileType = strstr(strtolower($_FILES['picture']['name']),'.');
if(($fileType==".jpg")||($fileType==".gif")||($filetype==".png"))
{
$rand = rand(00000000000,99999999999999);
$getFileName = $rand.$fileType;
if(move_uploaded_file($_FILES['picture']['tmp_name'],$CFG['folderphoto'].$getFileName)){
chmod($CFG['folderphoto'].$getFileName, 0755);
$img_resize = new hft_image($CFG['folderphoto'].$getFileName);
$img_resize->resize($CFG['photo_w_index'],$CFG['photo_h_index'],"-");
$img_resize->output_resized($CFG['folderthumbindex'].$getFileName);
$img_resize = new hft_image($CFG['folderphoto'].$getFileName);
$img_resize->resize($CFG['photo_w_album'],$CFG['photo_h_album'],"-");
$img_resize->output_resized($CFG['folderthumb'].$getFileName);
}
}
$strSQL = "INSERT INTO userinfo (login,passwd,name,age,sex,picture,crew,email,facebook,hifive,ip,date,time)
VALUES
('$login','$passwd','$name','$age','$sex','$picture','$crew','$email','$facebook','$hifive','$ip','$date','$time')";
$objQuery = mysql_query($strSQL);
if($objQuery){
echo "คุณลงทะเบียนสำเร็จแล้ว ";
header("location:index.php");
}
else{
echo "กรุณาลงทำเบียนใหม่อีกครั้ง";
}
}
}
mysql_close($connect);
?>
</body>
</html>
|
|
|
|
|
Date :
2009-11-09 18:43:11 |
By :
yacoolz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คับ เช็คก่อนบันทึกนะคับ คือเช็คข้อมูลก่อนทั้งหมด แล้วถ้าไม่ถูกต้อง ก็ไม่ต้องบันทึก
|
|
|
|
|
Date :
2009-11-09 20:42:27 |
By :
pjgunner |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ true , false ช่วยในการ เช็คสถานะ ครับ
เช่น if(empty($login)) {
....
return false;
}
|
|
|
|
|
Date :
2009-11-09 22:20:56 |
By :
aknueng |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|