First of all I am developing a mobile application using phonegap / cordova so this is the reason I am looking to go this route.
I am wondering is it possible to get session status from php into javascript as I'm looking to secure my whole application to users only.
The php I have is as follows;
<?php
$dbhost = '';
$dbuser = '';
$dbpass = '';
$db = '';
$tbl_name="";
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$encrypt_password=md5($mypassword);
$myusername = stripslashes($myusername);
$mypassword = stripslashes($encrypt_password);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($encrypt_password);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
session_start();
$_SESSION["Login"] = "YES";
header("location:login_success.html");
echo $_SESSION['data'];
}
else {
session_start();
$_SESSION["Login"] = "NO";
echo $_SESSION['data'];
}
?>
and the html file contains the following javascript
<script>$.get('checklogin.php', function(data) {
if (data != "YES"){
window.location.replace("http://aam.prettypottery.ie/index.html");
}
});</script>
I think I am close, only everytime I try to look at any of my html pages, they're all sending me back to the index.html.
Any help would be great. Thanks