亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP development message board to post messages

When we process the data passed by html on the PHP page, we must first determine whether the data passed is empty and whether the verification code is correct, and then insert the data passed by our html into the database

1.jpg

The code is as follows

<?php
session_start();
header("content-type:text/html;charset=utf-8");
$name=$_POST['name'];
$email=$_POST['email'];
$content=$_POST['content'];
$vcode=$_POST['vcode'];
if($name==''){
    echo "<script>alert('請輸入你的姓名');location='" . $_SERVER['HTTP_REFERER'] . "'</script>";
    exit;
}
if($content==''){
    echo "<script>alert('留言內(nèi)容不能為空');location='" . $_SERVER['HTTP_REFERER'] . "'</script>";
    exit;
}
if($vcode!=$_SESSION['VCODE']){
    echo"<script>alert('你的驗(yàn)證碼不正確,請重新輸入');location='".$_SERVER['HTTP_REFERER']. "'</script>";
    exit;
}
$conn=mysqli_connect('localhost','root','root','ressage');
mysqli_set_charset($conn,'utf8'); //設(shè)定字符集
if($conn){
    $sql=mysqli_prepare($conn,"insert into ressage_user(name,email,content,ressage_time) VALUES (?,?,?,now())");
    $param=mysqli_stmt_bind_param($sql,'sss',$name,$email,$content);
    $result=mysqli_stmt_execute($sql);
if($result){
    echo "<script>alert('留言成功');location.href='ressage.php';</script>";
}else{
    echo"<script>alert('你的留言失敗,請稍后重試');location.href='ressage.php';</script>";
    exit;
}
}else{
    die("數(shù)據(jù)庫連接失敗".  mysqli_connect_error());
}




Continuing Learning
||
<?php session_start(); header("content-type:text/html;charset=utf-8"); $name=$_POST['name']; $email=$_POST['email']; $content=$_POST['content']; $vcode=$_POST['vcode']; //if($name==''){ // echo "<script>alert('請輸入你的姓名');location='" . $_SERVER['HTTP_REFERER'] . "'</script>"; // exit; //} //if($content==''){ // // echo "<script>alert('留言內(nèi)容不能為空');location='" . $_SERVER['HTTP_REFERER'] . "'</script>"; // exit; // //} //if($vcode!=$_SESSION['VCODE']){ // // echo"<script>alert('你的驗(yàn)證碼不正確,請重新輸入');location='".$_SERVER['HTTP_REFERER']. "'</script>"; // exit; //} $conn=mysqli_connect('localhost','root','root','ressage'); mysqli_set_charset($conn,'utf8'); //設(shè)定字符集 if($conn){ $sql=mysqli_prepare($conn,"insert into ressage_user(name,email,content,ressage_time) VALUES (?,?,?,now())"); $param=mysqli_stmt_bind_param($sql,'sss',$name,$email,$content); $result=mysqli_stmt_execute($sql); if($result){ echo "<script>alert('留言成功');location.href='ressage.php';</script>"; }else{ echo"<script>alert('你的留言失敗,請稍后重試');location.href='ressage.php';</script>"; exit; } }else{ die("數(shù)據(jù)庫連接失敗". mysqli_connect_error()); }
submitReset Code