- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone i am currently working on a project using Intel XDK. I have made a mobile application which uses xampp to run mysql and apache server. This app asks the user to register an account by entering in their firstname, lastname, nhsnumber, email, username and password. When i test this on a browser (localhost) i can enter details in which are saved straight away to the database. When i test this on the emulator the following error appears:
Cannot POST /http-services/emulator-webserver/ripple/userapp/x/C/xampp/htdocs/xampp/Registeration/www/patient.php
Can anyone help me with this? I have been stuck for days :(
HTML:
<!DOCTYPE html>
<html>
<head>
<title>insert data in database using mysqli</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="main">
<h1>Insert data into database using mysqli</h1>
<div id="login">
<h2>Register Account</h2>
<hr/>
<Form Name ="form1" Method ="POST" ACTION = "patient.php">
<!--<form action="" method="post"> -->
<label>Firstname: </label>
<input type="text" name="pat_firstname" id="firstname" required="required" placeholder="firstname"/><br /><br />
<label>Lastname: </label>
<input type="text" name="pat_lastname" id="lastname" required="required" placeholder="lastname"/><br/><br />
<label>NHS Number: </label>
<input type="text" name="pat_nhsnumber" id="nhsnumber" required="required" placeholder="nhs number"/><br/><br />
<label>Email: </label>
<input type="email" name="pat_email" id="email" required="required" placeholder="email"/><br/><br />
<label>Username: </label>
<input type="text" name="pat_username" id="username" required="required" placeholder="username"/><br/><br />
<label>Password: </label>
<input type="password" name="pat_password" id="password" required="required" placeholder="password"/><br/><br />
<input type="submit" value=" Submit " name="submit"/><br />
</form>
</div>
<!-- Right side div -->
</div>
</div>
</body>
</html>
PHP:
<?php
if(isset($_POST["submit"])){
$servername = "localhost";
$username = "root";
$password = "XXXX";
$dbname = "hospital";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO patients (patient_firstname, patient_lastname, patient_nhsnumber, patient_email, patient_username, patient_password)
VALUES ('".$_POST["pat_firstname"]."','".$_POST["pat_lastname"]."','".$_POST["pat_nhsnumber"]."','".$_POST["pat_email"]."','".$_POST["pat_username"]."','".$_POST["pat_password"]."')";
if ($conn->query($sql) === TRUE) {
echo "<script type= 'text/javascript'>alert('New record created successfully');</script>";
} else {
echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";
}
$conn->close();
}
?>
I am using phpmyadmin to create the database 'hospital'.
- Tags:
- HTML5
- Intel® XDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Oonagh,
I came as you from php+mysql web development.
My first attempt was to create a set of php files to query the database and give me the JSON.
It was a simple job, but totally insecure what I did in some hours of work.
Then I found dreamfactory.com, an opensource software that automatically creates the REST API functions from several databases, SQL and NoSQL.
I use it a lot. You can start with a free account to develop and test and then install it in your server.
Another possibility is phprestsql.sourceforge.net, this is a library that does what I try to develop myself. I didn´t try it, but perhaps helps you.
And finally, I'm using in XDK PouchDB and CouchDB "A database for the web". It is NoSQL, very useful and easy if you need to develop a mobile app with not many tables.
It will work too with a lot of tables, but for a simple database is easy to start.
I strongly recommend that start to learn this ways to interact to databases, you will need to invest some time but is the way to go, don´t try to use MySQL and php the old fashioned way, you can get it work but at some time you may get stuck.
Best wishes,
Diego
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your XDK app is not a page on a web server, so the technique you are using will not work, because there is no web server to pass off that script to, you are building a client web app, not a server web app. You need to create a RESTful API on your server that you can call from your client (the XDK app) and pass and return data through that RESTful API (usually in the form of JSON).
Please see this SO post > http://stackoverflow.com/questions/11052318/not-able-to-execute-a-php-file-in-phonegap-android-platform < and this article by Ray Camden, a longtime developer of the Cordova development environment > http://www.raymondcamden.com/2012/05/05/converting-a-dynamic-web-site-to-a-phonegap-application/ <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Oonagh,
I came as you from php+mysql web development.
My first attempt was to create a set of php files to query the database and give me the JSON.
It was a simple job, but totally insecure what I did in some hours of work.
Then I found dreamfactory.com, an opensource software that automatically creates the REST API functions from several databases, SQL and NoSQL.
I use it a lot. You can start with a free account to develop and test and then install it in your server.
Another possibility is phprestsql.sourceforge.net, this is a library that does what I try to develop myself. I didn´t try it, but perhaps helps you.
And finally, I'm using in XDK PouchDB and CouchDB "A database for the web". It is NoSQL, very useful and easy if you need to develop a mobile app with not many tables.
It will work too with a lot of tables, but for a simple database is easy to start.
I strongly recommend that start to learn this ways to interact to databases, you will need to invest some time but is the way to go, don´t try to use MySQL and php the old fashioned way, you can get it work but at some time you may get stuck.
Best wishes,
Diego
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for those excellent suggestions, Diego! :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for your advice :) really appreciate it!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page