留言板


session_start();

$this_url="message.php";

if($_POST["hidden_myform"]=="saveok")
{

    $str_number = trim($_POST['checkID']);
    if(strtolower($_SESSION['yzm'])!=strtolower($str_number)){
    //echo "<script>alert('驗證碼錯誤');location.href='".$this_url."'<//script>";
        
        alert('驗證碼錯誤','back');
        exit;
     
    }else{
        
    $title=$_POST["title"];
    $content=$_POST["content"];
    $a1=$_POST["a1"];
    $a2=$_POST["a2"];
    $a3=$_POST["a3"];
    $a4=$_POST["a4"];
    
$a5=$_POST["a5"];
$a6=$_POST["a6"];
$a7=$_POST["a7"];
$a8=$_POST["a8"];
$a9=$_POST["a9"];
$a10=$_POST["a10"];

    $ly_addDate=date("Y-m-d H:i:s",strtotime(now));
    
$sql="insert into news(classId,title,content,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,addDate) value ('12','$title','$content','$a1','$a2','$a3','$a4','$a5','$a6','$a7','$a8','$a9','$a10','$ly_addDate')";
    $conn->query($sql);
    echo "<script>alert('提交成功!');location.href='".$this_url."'</script>";
    
    }

}

?>


        <form method="post" action="" name="myform" id="myform" >
        <input type="hidden" name="hidden_myform" value="saveok" />

        <input type="text" name="checkID" id="checkID" class="txt" style="width:100px;" /><img src="php_yzm.php"   alt="看不清楚可點擊這裏更換!" onclick="javascript:this.src=this.src+'?time='+Math.random()" style="margin:-5px 10px; height:20px;"/>

 

         <input type="submit" value="提 交" class="btn" formchk()"/>

         </form>




<script language="JavaScript">
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

<!--
function formchk(){
 var addform=document.myform;
 
 var title=addform.title;
 
 var content = addform.content;
 
 var tel=addform.a1;
 
 var email=addform.a2;
 
 
    if (title.value.length<2){
          alert("請填寫2-4個字的姓名!");
          title.focus();   //用戶名輸入框獲得焦點
          return false;   //不提交表單
    }
    
      
    if (tel.value.substr(0,1)!=1)
    {
         alert("手機號錯誤");
         tel.focus();
         return false;
    }
    
 
    var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if(!myreg.test(email.value)){
             alert("郵箱格式不正確!");
             email.focus();
             return false;
    }
    
    if (checkspace(content.value)){
        alert("該選項不能爲空!");
        content.focus();   //用戶名輸入框獲得焦點
        return false;   //不提交表單
    }
    
   return true;   //輸入符合要求後執行表單提交操作 addform.submit();
}

//-->
</script>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章