Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript出现问题,警报未显示_Javascript_Php - Fatal编程技术网

javascript出现问题,警报未显示

javascript出现问题,警报未显示,javascript,php,Javascript,Php,嗨,我注册了这个数据库,注册了新用户,但是注册用户的JavaScript警报不起作用,但是同一页面上登录用户的示例正在起作用。。。我的意思是,如果你的密码失败,它将显示密码是错误的,但如果你试图注册用户进入数据库,但没有任何警告说“新记录创建成功” -----------------------------------注册到数据库并发出警报---------------------- <?php session_start(); $db=mysqli_connect("l

嗨,我注册了这个数据库,注册了新用户,但是注册用户的JavaScript警报不起作用,但是同一页面上登录用户的示例正在起作用。。。我的意思是,如果你的密码失败,它将显示密码是错误的,但如果你试图注册用户进入数据库,但没有任何警告说“新记录创建成功”

-----------------------------------注册到数据库并发出警报----------------------

<?php
    session_start();

    $db=mysqli_connect("localhost","root", "","compras");
    if(isset($_POST['signup'])) {

        $fname = ($_POST['fname']);
        $lname = ($_POST['lname']);
        $password = ($_POST['password']);
        $email = ($_POST['email']);
        $phone = ($_POST['phone']);
        $sql;
        $password=md5($password);

if (!$db) {
    die("Connection failed: " . mysqli_connect_error());
}
$sql = "Insert into users(fname,lname,phone,email,password) values ('$fname','$lname','$phone','$email','$password')";

if (mysqli_query($db, $sql)) 
{
    echo '<script type="text/javascript">alert("New record created successfully");</script>';

    header("Location:http://localhost/Fly With US/index.php");
} 
else 
{
    echo '<script type="text/javascript">alert("Error Occured");</script>';
    header("Location:http://localhost/Fly With US/index.php");

    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

    }
?>
    <?php
session_start();
if(isset($_SESSION['username'])){
    header("Location: cat_type.php");
}
?>
 <html>
 <head>
<link rel="stylesheet" href="css/head.css">
<link rel="icon" href="res/flywithus-pt.png" sizes="16x16">
<link href="https://fonts.googleapis.com/css?family=Bgrree+Serif" rel="stylesheet">
<script type="text/javascript" src="scripts/signupForm.js"></script>
<script type="text/javascript" src="scripts/loginForm.js"></script>
<title>Fly With Us | Buy Drones and Computers.</title>
</head>
<body>
<h1><center><img src="res/flywithus-png.png"></center></h1>



<!-- LOGIN -->

<div id="login">
<form name="loginForm" method="post" action="log.php">
<table align="left" width="150%">
<tr>
    <td align="center">
        <h2>Login</h2>
    </td>
</tr>
<tr>    
    <td>
        <input type="text" name="username" id="user" placeholder="Email" required>
    </td>   
</tr>
<br>
<tr>    

    <td>
        <input type="password" name="password" id="pass" placeholder="Password" required>
    </td>
</tr>
<tr>

    <td>
        <input type="submit" name="login" value="Let me in.." class="click">
    </td>
</tr>
<!--
<tr>
    <td colspan="2" class="signin">
        <input type="image" src="signin_google.png" alt="Login with Google" width="50%" height="50%">

    </td>
</tr>
<tr>
    <td colspan="2" class="signin">
        <input type="image" src="signin_fb.png" alt="Login with FB" width="50%" height="50%">

    </td>
</tr>
//-->
</table>
</form>
</div>


<!-- SIGNUP -->

<form name="signupForm" method="post" action="pro.php" id="signup" onsubmit="return ValidateFname() || ValidateLname() || ValidateEmail() || ValidateMobile() ">
<table align="right"> 
<tr>
    <td align="center" colspan="2">
        <h2>New Here? Register with us..</h2>
    </td>
</tr>
<tr>
    <td>
        <input type="text" name="fname" placeholder="First Name" required>  
    </td>
    <td>
        <input type="text" name="lname" placeholder="Last Name" required>
    </td>
</tr>

<tr>
    <td colspan="2">
        <input type="email" name="email" placeholder="Email" required>
    </td>
</tr>
<tr>
    <td colspan="2">
        <input type="text" name="phone" placeholder="Contact Number" required>
    </td>
</tr>
<tr>    
    <td colspan="2">
        <input type="password" name="password" placeholder="Password" required>
    </td>
</tr>

<tr>
<td colspan="2">
    <input type="submit" name="signup" value="Sign Up" class="click">
</td>
</tr>

</table>
</form>

</body>
</html>
这是因为PHP(
标题
)仍将在JavaScript(
警报
)之后读取。换句话说,实际上显示了
警报
,但同时加载了
index.php
,因此警报似乎不显示

不起作用:

echo '<script type="text/javascript">alert("Error Occured");</script>';
header("Location:http://localhost/Fly With US/index.php");
echo'警报(“发生错误”);
标题(“位置:http://localhost/Fly 使用US/index.php“;
将工作:

echo '<script type="text/javascript">
    alert("Error Occured");
    window.open("index.php","_self");
</script>';
echo'
警报(“发生错误”);
open(“index.php”,“_self”);
';
这是因为PHP(
标题
)仍将在JavaScript(
警报
)之后读取。换句话说,实际上显示了
警报
,但同时加载了
index.php
,因此警报似乎不显示

不起作用:

echo '<script type="text/javascript">alert("Error Occured");</script>';
header("Location:http://localhost/Fly With US/index.php");
echo'警报(“发生错误”);
标题(“位置:http://localhost/Fly 使用US/index.php“;
将工作:

echo '<script type="text/javascript">
    alert("Error Occured");
    window.open("index.php","_self");
</script>';
echo'
警报(“发生错误”);
open(“index.php”,“_self”);
';

哦,老兄,非常感谢你的帮助!这很有帮助,也很有效,只要改变成功和错误这两件事就行了!!谢谢你能帮我做点别的吗?哦,老兄,非常感谢你的帮助!这很有帮助,也很有效,只要改变成功和错误这两件事就行了!!谢谢你能帮我做点别的吗?