加入判斷是否有括弧及空白

edited 六月 2014 in PHP新手區
各位大大好
我想要在程式中加入判斷
申請帳號時有空白鍵及括號時無法申請
$StNo0 是帳號
<?php
ob_start();
session_start();

//--------------------------------------------------------
   function search_StNo($StNo0,$con)
    {   $sql = "SELECT * FROM member_table where StNo = '$StNo0'";
        $result0 = mysql_query($sql,$con);   

        if(mysql_fetch_row($result0))
        {   return  true;   	    }
        else
        {    return false;        }
		mysql_free_result($result0);
   }
    //----------------------------------------------------------------------------------------
   function insertAccPass($StNo0,$pw1,$pw2,$con) 
   {        
      date_default_timezone_set('Asia/Taipei');
      $today0 = date("Y-m-d g:i:s");
      if ( $pw1==$pw2)
      {   $sql = "insert into member_table (StNo,Password,Date) values 
                                       ('$StNo0','$pw1','$today0')";
		 							      
         if(mysql_query($sql,$con))
         {       return true;      }
         else
         {      return false;      } 
      }	
      else
                return false; 	  
   } 
 //====================================================================
$pw1 = $_POST['P_pw1'];
$pw2 = $_POST['P_pw2'];
$StNo0=$_POST['P_StNo'];
include ("..\OpenMyDB.php");


if (search_StNo($StNo0,$con))
{   echo "有同名帳號者存在,請另設帳號!";
  
}
else
{  
    InsertAccPass($StNo0,$pw1,$pw2,$con);
    echo($name.'已設定完成!');
}
?>
<a href="..\login.htm">回登入頁</a>
Sign In or Register to comment.