如何将Android应用程序连接到数据库? [英] How to connect android app to database?

查看:108
本文介绍了如何将Android应用程序连接到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建我的网站的Android应用程序。我想知道在我的php文件中需要进行哪些更改才能将我的Android应用程序连接到我的网站的数据库,因为这些文件没有echo语句或者我必须创建另一个php文件用于这些目的。请帮忙,因为我是android的新手。

我的第一个文件是login.php

I am creating android app of my website.I want to know which changes are necessary to make in my php files in order to connect my android app to my website's database as these files have no echo statement or I have to make another php files for these purpose.Please help as I am new to android.
My first file is login.php

<?php require_once('Connection/cnn.php'); ?>
<?php

session_start();

if((isset($_POST['admin_login'])) && ($_POST['admin_login']=="form99"))

{

$_SESSION['username']=$_POST['txt_email'];

$_SESSION['password']=$_POST['txt_password'];

header('Location: login-pass.php');

}

if($_SESSION['verified']=='Y')

{

    header('Location: transporter-account.php');

}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Transporteazy</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/main.js"></script>
</head>

<body>

<!-- MAIN BODY WRAPPER START -->
<div id="main-Body-Wrapper">

<!-- HEADER PART START -->
<div id="header-con">
    <?php include ('header.php'); ?>
</div>
<!-- HEADER PART END -->





<!-- MIDDLE PART START -->
<div class="how-it-work">
    <div class="left-part">
    <?php if($_GET['msg']=='error') {?>
<h1>Please login below to see posted loads or <a href="transporter-registration.php" target="_self">click here</a> to register with us.</h1>
<?php } else {?>
<h1>Login Area</h1>
<?php } ?>
            <div class="login">
            <?php $page=$_SERVER['QUERY_STRING'];

        if ($page!="") {        ?>
        <div class="error">
        <?php if ($_GET['error']=="empty") { ?>
        <p class="alert">Please enter user name & password.</p>
        <?php } else if ($_GET['error']=="name") {?>
        <p class="alert">Please enter user name.</p>
        <?php } else if ($_GET['error']=="pass") {?>
        <p class="alert">Please enter password.</p>
        <?php } else if ($_GET['error']=="nouser") {?>
        <p class="alert">Something is wrong.</p>
        <?php } else if ($_GET['error']=="pend") {?>
        <p class="alert">You are not a authorize person to access further pages.</p>
        <?php }?>
        </div>
        <?php }?>
                <h3>If you are already registered, please login here.</h3>
                <div class="loginBox">
                    <form name="login-form" id="login-form" method="post">
                    <table width="420" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="150" align="right" valign="middle">Email Address :</td>
                        <td align="left" valign="top"><input name="txt_email" type="email" class="input" id="txt_email" value="" required placeholder="abc@xyz.com"/></td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle">Password:</td>
                        <td align="left" valign="top"><input name="txt_password" type="password" class="input" id="txt_password" value="" required placeholder="*********"/></td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle">&nbsp;</td>
                        <td align="left" valign="top"><input name="Submit" type="submit" class="loginBtn" value="" />
                        <input type="hidden" name="admin_login" value="form99"/></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top">&nbsp;</td>
                        <td align="left" valign="top">&nbsp;</td>
                      </tr>
                      <tr>
                        <td align="right" valign="top">&nbsp;</td>
                        <td align="left" valign="top"><a href="forgot-password.php" target="_self">Forgot Password?</a>  <font color="#FF0000">|</font> <a href="transporter-registration.php" target="_self">Register here</a></td>
                      </tr>
                    </table>
                    </form>
        </div>
      </div>
    </div>




    <!-- RIGHT PART -->
        <div class="right-part">

                <?php include('benefits.php');?>

        </div>
    <!-- RIGHT PART -->


</div>
<!-- MIDDLE PART END -->




<!-- FOOTER PART STRAT -->
    <div class="footerCon">
        <?php include ('footer.php'); ?>
    </div>
    <!-- FOOTER PART END -->


</div>
<!-- MAIN BODY WRAPPER END -->
</body>
</html>

推荐答案

_POST['admin_login'])) && (
_POST['admin_login'])) && (


_POST['admin_login']==\"form99\"))

{

_POST['admin_login']=="form99")) {


_SESSION['username']=
_SESSION['username']=


这篇关于如何将Android应用程序连接到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆