dongmai6666 2014-03-12 12:23
浏览 36

带有移动应用程序的PHP Web服务

I want to create a mobile application with phonegap winch connect to an external oracle database. I need first create a web service you can see my code and tell me if what i create is considerate a web service

index.html

<html><head>
<script src="jquery.min.js"></script>
<script src="jsjsjs.js"></script>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id='logindiv'>

        <label>Username:</label>
            <input name="username"  id="username" type="text">
        <label>Password:</label>
            <input name="password" id="password" type="password">
            <input value="Submit" name="submit" class="submit" type="submit" onclick='chk_ajax_login_with_php();'>
        <div id='status'></div>
</div>   
</body>
</html>

my jsjsjs.js

    <script>
function chk_ajax_login_with_php(){
  var username=document.getElementById("username").value;
  var password=document.getElementById("password").value;

    var params = "username="+username+"&password="+password;
           var url = "http://192.168.1.14/test_login/login.php";
                $.ajax({
                               type: 'POST',
                               url: url,
                               dataType: 'html',
                               data: params,
                               beforeSend: function() {
                                 document.getElementById("status").innerHTML= 'checking...'  ;
                                         },
                               complete: function() {

                               },
                               success: function(html) {


                                     document.getElementById("status").innerHTML= html;
                                     if(html=="success"){

                                       window.location = "http://192.168.1.14/test_login/test.php"

                                     }

                                }
                       });

}
</script>

login.php

 <?php
session_start();
try {
$dbh = oci_connect('test_bd', '123456', 'localhost/XE');
} catch (PDOException $e)
{
    echo $e->getMessage();
}
if ($_POST['username'] != null and $_POST['username'] != "" and $_POST['password'] != null and $_POST['password'] != "")
{
$username = $_POST['username'];
$password = $_POST['password'];
$sth = oci_parse($dbh ,"SELECT * FROM utilisateur WHERE LOGIN='$username' and PASS='$password'");
oci_execute($sth);
if(oci_fetch($sth)){
       echo "Nice";
    }
    else { echo "nono";}



}     
?>    
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab实现基于主成分变换的图像融合。
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊