简体   繁体   English

用PHP显示jQuery警报

[英]Displaying jquery alerts with PHP

Hi I'm new to PHP and everything is very confusing to me. 嗨,我是PHP的新手,一切都让我感到困惑。 What I'm trying to do and fail is to display an alert on the screen on click of a button on the page. 我要执行的失败操作是单击页面上的一个按钮在屏幕上显示警报。

my Code signInFunction.php: 我的代码signInFunction.php:

<?php
if(isset($_POST['signIn'])){
    if(isset($_POST['username']) and isset($_POST['password'])){
        $username = $_POST['username'];
        $password = $_POST['password'];

        ?>
        <script type="text/javascript">alert("test");</script>
        <?php
        echo "username is: ".$username." and password is: ". $password;
    }
    else{
        echo "Please enter username and password";
    }
}
else{
    echo "error button";
}
?>

in the index.php file looks like this: 在index.php文件中看起来像这样:

  <?php include "includes/header.php" ?>
  <?php include "includes/navbar.php" ?>
  <?php include "includes/carousel.php"?> 
  <?php include "includes/marketing.php"?> 
  <?php include "includes/features.php"?>
  <?php include "includes/hidden.php"?>
  <?php include "includes/footer.php" ?>
  <?php include "includes/functions/signinFunction.php"?>

The Problem is that I manage to display the data at the bottom but fail to make the alert appear.. what am I missing? 问题是我设法在底部显示数据,但未能使警报出现..我缺少什么?

<form action="" method="post" >
   <input name='username' type='text' value=''/>
   <input name='password' type='text' value='' />
   <input type='button' name='signIn' value='Sign In' />
</form>
<?php
if(isset($_POST['signIn'])){
    if(isset($_POST['username']) and isset($_POST['password'])){
        $username = $_POST['username'];
        $password = $_POST['password'];

        ?>
        <script type="text/javascript">alert("test");</script>
        <?php
        echo "username is: ".$username." and password is: ". $password;
    }
    else{
        echo "Please enter username and password";
    }
}
else{
    echo "error button";
}
?>

when u click on the sign in button then that alert should appear 当您单击登录按钮时,该警报应出现

echo '<script language="javascript">';
echo 'alert("alert")';
echo '</script>';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM