doudou8081 2016-04-03 10:19
浏览 47

使用post进行PHP表单处理没有打印

I am trying check if username or email already exists . This is my form

<form role="form" action="kys_SignUp.php" method="post">
                <div class="form-group">
                                         <label for="email" >Email address:</label>
                                         <input type="email" style="width: 300px" class="form-control"  name="email" id="email" required>
                    </div>

             <div class="form-group">
                                         <label for="Username" >Username:</label>
                                         <input type="text" style="width: 300px" class="form-control" name="username" id="Username" required>
                    </div>

                <div class="form-group">
                                         <label for="password" >Password:</label>
                                         <input type="password" style="width: 300px" class="form-control" id="password" name="password" required>
                    </div>

                   <button type="submit"  class="btn btn-default">Submit</button>

            </form>

I am sending the data in Post Method. My server side script looks like this

<?php 

 include "kys_DbConnect.php";

$email = $username = $password = "";

if($_SERVER["REQUEST_METHOD"] == "POST"){

    $email = cleanData($_POST["email"]);
    $username = cleanData($_POST["username"]);
    $password = cleanData($_POST["password"]);


}



    $stmt = $con->prepare("SELECT * FROM kys_users WHERE username=? OR email=?");
    $stmt->bind_param("ss",$username,$email);
    $stmt->execute();
    $stmt->bind_result($id,$email,$username,$password);
     $stmt->fetch();

    if($username == ""){

       header("Location : http://localhost/KeyStroke/index.html ");
        exit();
    }  
   else{

        echo "Username or Email already exists";

   }



function cleanData($data){

    $data = stripslashes($data);
  $data = htmlspecialchars($data);
    return $data;

}



?>

This is my kys_DbConnect.php

 <?php
     $serverName = "localhost";
    $username = "jois";
    $password = "iluvcoding";
    $db_name = "kys_userdata";    

    $con = new mysqli($serverName,$username,$password,$db_name);



    if($con->connect_error){

        echo "Connection Error";

    }
?>

I don't know why but it print's nothing nor redirects to index.html (index.html exists). How can I figure out what's wrong with my code?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法