|
 |
|
ช่วยเพิ่มเติมให้หน่อยนะคะ คือเพิ่มโค้ดไม่ค่อยเป็นอะคะ คืออยากจะให้ข้อความที่จะแสดง ให้มันแสดงอยู่ในหน้าสมัครสมาชิกเลยอะคะ |
|
 |
|
|
 |
 |
|
คืออยากจะให้ข้อความที่จะแสดง ให้มันแสดงอยู่ในหน้าสมัครสมาชิกเลยอะคะ
ช่วยเติมให้หน่อยนะคะ ไปหากระทู้ที่ผ่านมา ไม่ค่อยเข้าใจเท่าไหร่ คือเป็นมือใหม่หัดทำอะคะ
ไม่รู้จะเอาโค้ดมาใส่ตรงไหน
Code (PHP)
<?php
$host = "localhost";
$user = "root";
$passwd = "root";
$dbname = "register";
mysql_connect($host,$user,$passwd) or die("ติดต่ิอ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
$sql = "insert into `userinfo` ( `logname` , `pw` , `name` , `day` , `month` , `year` , `sex`, `age` , `address` , `province` , `code`, `idnumber` , `phone` , `email` )
values ('$logname', '$pw', '$name', '$day', '$month', '$year', '$sex', '$age', '$address', '$province', '$code', '$idnumber', '$phone', '$email')";
mysql_query("set NAMES tis620");
$sqlquery=mysql_db_query($dbname, $sql);
$checkadd = "select * from `userinfo` where logname='$logname' ";
$result = mysql_db_query($dbname, $checkadd);
$num=mysql_num_rows($result);
if ($num==1)
{
print"<br>เพิ่มข้อมูลผู้ใช้ลงในฐานข้อมูลเรียบร้อยแล้ว ";
}elseif($num>=1)
{
print"<br>ชื่อผู้ใช้งานซ้ำ กรุณาใช้ชื่ออื่น";
}else
{
print"<br>ระบบขัดข้อง หรือ มีข้อผิดพลาด!!!";
};
mysql_close();
?>
Tag : PHP, Ajax

|
|
 |
 |
 |
 |
Date :
2011-12-01 11:47:44 |
By :
korawik |
View :
745 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าสมัครของคุณอยู้หน้าเดียวกับโค๊ตชุดนี้หรือป่าว ถ้าไม่ก็ ลอง ส่งกับ เป็น ค่า GET หรือ SESSION ดูครับ แล้ว หน้าสมัครสมาชิกก็เช็คเอา
|
 |
 |
 |
 |
Date :
2011-12-01 11:55:21 |
By :
taza678 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
mysql_connect("localhost","root","root");
mysql_select_db("mydatabase");
if(trim($_POST["txtUsername"]) == "")
{
echo "Please input Username!";
exit();
}
if(trim($_POST["txtPassword"]) == "")
{
echo "Please input Password!";
exit();
}
if($_POST["txtPassword"] != $_POST["txtConPassword"])
{
echo "Password not Match!";
exit();
}
if(trim($_POST["txtName"]) == "")
{
echo "Please input Name!";
exit();
}
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['txtUsername'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "Username already exists!";
}
else
{
$strSQL = "INSERT INTO member (Username,Password,Name,Status) VALUES ('".$_POST["txtUsername"]."',
'".$_POST["txtPassword"]."','".$_POST["txtName"]."','".$_POST["ddlStatus"]."')";
$objQuery = mysql_query($strSQL);
echo "Register Completed!<br>";
echo "<br> Go to <a href='login.php'>Login page</a>";
}
mysql_close();
?>
Go to : PHP MySQL กับ Register Form ทำระบบ สมัครสมาชิกเก็บข้อมูลง่าย ๆ เช่น รหัสสมาชิก (Username) รหัสผ่าน (Password)
|
 |
 |
 |
 |
Date :
2011-12-01 12:59:16 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|