1

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";}



}     
?>    
Rikesh
  • 26,156
  • 14
  • 79
  • 87
user3309857
  • 43
  • 1
  • 8
  • that isn´t a web service, it´s just an ajax callback – Tommy Mar 12 '14 at 12:36
  • web service must be a rest or soap ??? i can't create my own !! – user3309857 Mar 12 '14 at 12:40
  • example of a soap web service: http://www.codeproject.com/Tips/671437/Creating-Web-Service-Using-PHP-Within-Minutes – Qarib Haider Mar 12 '14 at 12:42
  • You need to choose one of them looking at your specifications, i mean mainly performance. You could check [this](http://stackoverflow.com/questions/4163066/rest-vs-soap-has-rest-a-better-performance) and decide what you exactly need – Tommy Mar 12 '14 at 12:42

0 Answers0