I am trying to validate user credential from my app login page within codename1 by accessing a web sever php code that validates the user login credential against a database on the web server.
i have little idea about the connection form my codename1 app to the php web server script can anyone provide a little clarity please. i need to help with understanding the
Connection request and connecting to the php script that performs the validation and return the result to m app.
<?php
session_start();
if($_POST)
{
$username=$_POST['Name'];
$password=$_POST['pass'];
//Pull file into program to retrieve username,password,database name and server name
$file1=file(path to text file);
//use to stor values from topsecret file into varibles
$dbserver=trim($file1[0]);
$uid=trim($file1[1] );
$pw=trim($file1[2]);
$dbname=trim($file1[3]);
//connect to database with varibles
$link=mysqli_connect($dbserver, $uid, $pw, $dbname)
or die('could not connect:'. mysqli_error($link));
//sql query to display data that matches price range and product
$query = 'Select * from users where username LIKE"%' . $username . '"
and password LIKE "%'. $password .'%"';
$query = mysqli_query($link, $query) or die('query failed'. mysqli_error($link));
$num=(mysqli_num_rows($query));
//if user values doesnt matches any value in the database javascript is executed and infrom user that no product fits thier values
if($num <1){
echo '<script language="javascript">';
echo 'alert("Login Credentials invalid")';
echo '</script>';
echo '<script type="text/javascript">
</script>';
}
if($num >0)
{
$_SESSION['user']=$username;
}
}
?>
<html>
<title>Login Page</title>
</head>
<body>
<h1>Login Information</h1>
<tr>
<td> Username:</td>
<td><input name="Name" type="text" value=""></td> <td> <?php echo $erone; ?></td>
</tr>
<br><br>
<tr>
<td>Password:</td>
<td><input name="pass" type="password" value=""></td><td> <?php echo $ertwo; ?></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td></td>
<td><input name="submit" type="submit"></td>
</tr>
</form>
</body>
</html>