简体   繁体   English

如何使用PhoneGap iOS成功登录时重定向HTML页面?

[英]How to redirect HTML page on successful login using PhoneGap iOS?

I have designed a form using HTML and CSS and am using phpMyAdmin as backend where I can save user data and use it for login purposes. 我使用HTML和CSS设计了一个表单,并使用phpMyAdmin作为后端,我可以保存用户数据并将其用于登录目的。 I have successfully connected phpMyAdmin, saving data successfully and verifying it in login page. 我已成功连接phpMyAdmin,成功保存数据并在登录页面验证它。

Now my problem is if the login is successful it has to load HTML page empaccess.html . 现在我的问题是如果登录成功,它必须加载HTML页面empaccess.html I don't know to how to do it in PHP. 我不知道如何用PHP做到这一点。

Here is my PHP code (empcheck.php): 这是我的PHP代码(empcheck.php):

<?php   
$a=$_POST['text3'];
$b=$_POST['text4'];

mysql_connect("localhost","root","","crm");
mysql_select_db("crm") or die("Error in Connection");
if (empty($_POST['text3']) && empty($_POST['text4']))
{
  echo "<h1><center>PLEASE ENTER YOUR USERNAME AND PASSWORD</center></h1>";
  exit();
}
$query="SELECT * from emmreg WHERE username='$a'";
$result=mysql_query($query);
if($result)
{
    $row=mysql_fetch_assoc($result) or die("");
    $uname=$row['username'];
    $pwd=$row['password'];
     if($a==$uname && $b==$pwd)
     {

       echo "Success";
        //header('location:index.html');
      }

else
 {
   echo "INCORRECT PASSWORD";

 }
}mysql_close();
?>

PHP: PHP:

header('Location: http://example.com/page.php');        

Javascript: 使用Javascript:

<script type="text/javascript">
window.location = "http://www.example.com/";
</script>

HTML: HTML:

<meta http-equiv="Refresh" content="seconds; url=URL"> 

it'll redirect to another page on load. 它会在加载时重定向到另一个页面。

use header() , and dont try to echo or try to get any output before header function 使用header() ,并且不要尝试回显或尝试在header函数之前获取任何输出

if($result)
{
    $row=mysql_fetch_assoc($result) or die("");
    $uname=$row['username'];
    $pwd=$row['password'];
    if($a==$uname && $b==$pwd)
     {
      header('location:empaccess.html');
     }
     else
     {
     header('location:index.html');;

     }
}

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

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