|
|
|
ช่วยดูโค้ด PHP ใช้ AJAX เเล้วมันไม่บันทึกลง Database อะครับ |
|
|
|
|
|
|
|
ใช้ AJAX เเล้วมันไม่บันทึกลง Db อะครับ
Code (PHP)
<?
include("connect.php");
$strUsername = trim($_POST["tUsername"]);
if(trim($strUsername) == "")
{
echo "<img src='images/false.png'>";
exit();
}
$strSQL = "SELECT * FROM tb_member WHERE UserName = '".$strUsername."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<img src='images/false.png'>";
}
else
{
echo "<img src='images/true.png'>";
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
mysql_query("insert into tb_member (UserName,Password,FullName,Sex,EmailAdddress,Address,tel,Agencies,Position,Pic,Status) values ('$txtUsername','$txtPass','$txtname','$rdoGender','$txtemail','$editor1','$txtTel','$txtagencies','$txtposition','".
$_FILES["filUpload"]["name"]."','$select');" );
$tb_member_UserID = mysql_insert_id();
mysql_query("insert into tb_boss (UserID,BossName,BossAgencies,BossPosition,BossEmail) values
( '$tb_member_UserID','$txtname','$txtagencies','$txtposition','$txtemail')");
echo "<script>alert('Register Completed!');
window.location='Login.php';
</script>";
}
}
mysql_close();
?>
Tag : PHP
|
|
|
|
|
|
Date :
2013-04-30 22:05:37 |
By :
Kaen17 |
View :
755 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังเเก้ไมได้เลยครับ ไม่มี error อะไรเลย เเต่ข้อมูลไม่บันทึกลง DB ครับ AJAX ทำงานปกติครับ
|
|
|
|
|
Date :
2013-05-01 07:48:51 |
By :
Kaen17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเพิ่ม or die(mysql_error()); เข้าไปครับ
|
|
|
|
|
Date :
2013-05-01 17:39:09 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เพิ่มเเลว้ยังไม่ได้ครับ เหมือนเดิม
|
|
|
|
|
Date :
2013-05-01 18:15:37 |
By :
Kaen17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันน่าจะมี Error ส่งกลับมาครับ
|
|
|
|
|
Date :
2013-05-02 06:14:46 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่มีเลยครับ ขึ้นเครื่องหมาย echo "<img src='images/false.png'>"; อันนี้อะครับ
Code (PHP)
<?
include("connect.php");
$strUsername = trim($_POST["tUsername"]);
if(trim($strUsername) == "")
{
echo "<img src='images/false.png'>";
exit();
}
$strSQL = "SELECT * FROM tb_member WHERE UserName = '".$strUsername."' ";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<img src='images/false.png'>";
exit();
}
else
{
echo "<img src='images/true.png'>";
exit();
$sur = strrchr($_FILES['filUpload']['name'], ".");
$newfilename = (Date("dmy_His").$sur);
if(copy($_FILES["filUpload"]["tmp_name"],"myfile/".$newfilename.'.pdf'))
{
mysql_query("insert into tb_member (UserName,Password,FullName,Sex,EmailAdddress,Address,tel,Agencies,Position,Pic,Status) values ('$txtUsername','$txtPass','$txtname','$rdoGender','$txtemail','$editor1','$txtTel','
$txtagencies','$txtposition','$newfilename','$select');" );
$tb_member_UserID = mysql_insert_id();
mysql_query("insert into tb_boss (UserID,BossName,BossAgencies,BossPosition,BossEmail,BossTel) values
( '$tb_member_UserID','$txtname','$txtagencies','$txtposition','$txtemail','$txtTel')");
echo "<script>alert('Register Completed!');
window.location='Login.php';
</script>";
}
}
mysql_close();
?>
|
ประวัติการแก้ไข 2013-05-02 08:35:41
|
|
|
|
Date :
2013-05-02 08:31:06 |
By :
Kaen17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_POST["tUsername"] มีค่ามาหรือเปล่าครับ ลอง echo ตรงบรรทัดที่ 3 $strUsername = trim($_POST["tUsername"]); ดูครับ
|
|
|
|
|
Date :
2013-05-02 08:39:02 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
include("connect.php");
$strUsername = trim($_POST["tUsername"]);
if(trim($strUsername) == "")
{
echo "<img src='images/false.png'>";
exit();
}
$strSQL = "SELECT * FROM tb_member WHERE UserName = '".$strUsername."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
/*
return ค่า แล้วค่อยแสดงรูปน่าจะดีกว่านะครับ
*/
echo "<img src='images/false.png'>";
}
else
{
echo "<img src='images/true.png'>";
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"myfile/".$_FILES["filUpload"]["name"]))
{
$sql=" INSERT INTO tb_member (UserName, Password, FullName, Sex, EmailAdddress, Address, tel, Agencies, Position, Pic, Status) ";
$sql.=" VALUES ";
$sql.=" ('".$txtUsername."', '".$txtPass."', '".$txtname."', '".$rdoGender."', '".$txtemail."', '".$editor1."', '".$txtTel."', '".$txtagencies."', '".$txtposition."', '".$_FILES["filUpload"]["name"]."', '".$select."') ";
$qr=mysql_query($sql) or die (mysql_error());
$tb_member_UserID = mysql_insert_id();
$sql1=" INSERT INTO tb_boss ( UserID, BossName, BossAgencies, BossPosition, BossEmail ) ";
$sql1.=" VALUES ";
$sql1.=" ('".$tb_member_UserID."', '".$txtname."', '".$txtagencies."', '".$txtposition."', '".$txtemail."') ";
$qr1=mysql_query($sql1) or die (mysql_error());
/*
ถ้าใช้ ajax return ค่าแล้วค่อย alert น่าจะดีกว่านะครับ
echo "<script>alert('Register Completed!'); ";
echo "window.location='Login.php'";
echo "</script>";
*/
}
}
/*
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
mysql_close(); --> false
mysql_close($link); --> true
*/
?>
|
|
|
|
|
Date :
2013-05-02 08:45:51 |
By :
popnakub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|