|
|
|
สอบถามปัญหา PHP กับ Java Script หน่อยครับ เหมือนมันจะ alert มั่วๆๆ |
|
|
|
|
|
|
|
Code (PHP)
<?php
define("RelativePath", "./lib/");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
include(RelativePath . "/function.php");
$db = new clsDBfootball();
$db1 = new clsDBfootball();
$football=new football();
?><!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=windows-874">
<title><? echo CCDLookUp("title","config","",$db1);?></title>
<META name=Keywords content="<? echo CCDLookUp("description","config","",$db1);?>" >
<META content="<? echo CCDLookUp("keyword","config","",$db1);?>" name=Description>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/news-style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js" ></script>
<script type="text/javascript" src="js/jquery-ui.min.js" ></script>
<script type="text/javascript">
$(document).ready(function(){
$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
});
</script>
<script type="text/javascript" language="JavaScript1.2" src="stm31.js">
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="600" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><?php
include("header.php");
?></td>
</tr>
<tr>
<td height="600" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><?php
include("left.php");
?>
<br /></td>
<td width="768" valign="top">
<?php
if(!$_POST["rigis"]){
?>
<br />
<br />
<br />
<form id="myForm" name="myForm" method="post" action="register.php" onsubmit="check_space();">
<table width="400" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#0081A8">
<tr>
<td bordercolor="#FFFFFF"><table width="100%" border="0" align="center">
<tr>
<td height="28" colspan="2" align="center" background="images/menu_bg.jpg" style="background-repeat:repeat-x"><font color="#FFFFFF" size="+1"><strong>สมัครสมาชิก</strong></font></td>
</tr>
<tr>
<td>Username</td>
<td><input name="username" type="text" id="username" size="20" />
<span id="error1" style="color:#FF0000"></span> </td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" id="password" size="20" />
<span id="error2" style="color:#FF0000"></span> </td>
</tr>
<tr>
<td>ยืนยัน Password</td>
<td><input name="repassword" type="password" id="repassword" size="20" />
<span id="error3" style="color:#FF0000"></span> </td>
</tr>
<tr>
<td>E-mail</td>
<td><input type="text" name="email" id="email" />
<span id="error4" style="color:#FF0000"></span> </td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="rigis" id="button" value="สมัครสมาชิก" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#myForm").submit(function () {
var sm_status=true
if($("#username").val() == ''){
$("#error1").html("กรุณา Username")
sm_status=false;
}else{
$("#error1").html("")
}
if($("#password").val() == ''){
$("#error2").html("กรุณา Password")
sm_status=false;
}else{
$("#error2").html("")
}
if($("#repassword").val() == ''){
$("#error3").html("กรุณา ยืนยันPassword")
sm_status=false;
}else{
$("#error3").html("")
}
if($("#repassword").val() != $("#password").val()){
$("#error3").html("รหัสผ่านไม่ตรงกัน")
sm_status=false;
}else{
$("#error3").html("")
}
if($("#email").val() == ''){
$("#error4").html("กรุณา E-mail")
sm_status=false;
}else{
$("#error4").html("")
}
return sm_status
});
});
</script>
<br />
<?php
}
else{
$ins=0;
if (ereg(' ', $_POST["username"]))
{
$ins=1;
?>
<Script language = JavaScript>
alert("ชื่อผู้ใช้งานห้ามมีช่องว่างครับ")
window.history.back()
</Script>
<?
}
if (ereg(' ', $_POST["password"]))
$ins=1;
{
?>
<Script language = JavaScript>
alert("รหัสผ่านห้ามมีช่องว่างครับ")
window.history.back()
</Script>
<?
}
if (CCDLookUp("count(*)","member","email='".$_POST["email"]."'",$db1)!=0){
$ins=1;
?>
<Script language = JavaScript>
alert("อีเมล์นี้เป็นสมาชิกเว็บไซต์แล้ว")
window.history.back()
</Script>
<?
}
if (CCDLookUp("count(*)","member","username='".$_POST["username"]."'",$db1)!=0){
$ins=1;
?>
<Script language = JavaScript>
alert("ชื่อผู้ใช้นี้มีผู้ใช้งานแล้ว")
window.history.back()
</Script>
<?
}
if($ins!=1){
$db= new clsDBfootball();
$tdate = date("d/m/Y");
$sql="insert into member (username,password,email,group_id,regis_date) value ('".$_POST["username"]."','".$_POST["password"]."','".$_POST["email"]."',1,'".$tdate."')";
$result=$db->query($sql);
if($result){
echo "<br/><br/><br/><div align=center>สมัครสามชิกแล้ว กรุณา ล็อกอิน</div><br/>";
$football->login_form();
}
}
}
?>
</td>
</tr>
</table></td>
</tr>
<tr> <td height="70" bgcolor="#000000">
<?php
include("footer.php");
?></td>
</tr>
</table></td>
</tr>
</table>
<br />
</body>
</html>
ทำไมพอกด submit แล้วแสดงข้อความว่า รหัสผ่านห้ามมีช่องว่างครับ ทั้งๆที่รหัสผ่านไม่มีช่องว่างเลย
Tag : PHP
|
|
|
|
|
|
Date :
2012-08-23 01:58:22 |
By :
SoNFaiYen |
View :
1106 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function นี้มันทำงานแบบนี้ถูกต้องหรือเปล่าครับ
|
|
|
|
|
Date :
2012-08-23 08:23:42 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|