I'm currently working on a program that I plan on creating for multiple platforms using Xamarin. I'm currently working on a windows version of the app, and for safety reasons, I'm working on creating a PHP script that the application connects to. I have two PHP files that work together. One is login.php, the other is connect.php. connect.php contains the database information and looks as follows:
<?php
$host = "SERVERADDRESS";
$user = "USERNAME";
$pass = "PASSWORD";
$database = "login_info";
mysql_connect($host, $user, $pass);
mysql_select_db($database);
?>
And login.php looks as follows:
<?php
include("connect.php");
$isSuccessful = false;
$username = mysql_escape_string($_GET['username']);
$password = mysql_escape_string($_GET['password']);
$squery = mysql_query("SELECT * FROM users WHERE username='$username'");
$query = mysql_fetch_array($squery);
$rowcount = mysql_num_rows($squery);
if($rowcount == 1)
{
if($password != $query['password'])
{
echo 0;
}
else
{
echo 1;
$isSuccessful = true;
}
}
else
{
echo 2;
}
if($isSuccessful)
{
$returnString = $query['username'] . " " . $query['password'] . " " . $query['firstname'] . " " . $query['lastname'];
echo $returnString;
}
?>
In the C# program, I use the following line to upload and pull information:
report = new WebClient().DownloadString("http://WEBADDRESS/login.php?username=" + tbUser.Text + "&password=" + tbPass.Text);
As I have it setup right now, everything works like it should. The problem that I'm running into, is that for other operations of the program, I need to connect to different databases, other than 'login_info'.
Is there a way where I can give connect.php a string for the database variable, and supply login.php with the username and password provided by the user?