php mysql help
Posted: Wed Jan 28, 2015 8:39 pm
Hi all,
I have been playing around with php webservice for livecode, but need some help/explation as i am stuck.
I want t try the login but i guess its something wrong with my code.
php code*****
// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die( "Unable to select database $dbName");
// echo "Connected to MySQL";
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
//header("location:login_success.php");
echo "Connection sucess";
}
else {
echo "Wrong Username or Password";
}
?>
livecode***
on mouseUp
put field "uname" into tNam
put field "pword" into tWord
--put tWord && tNam into field "lf"
put tNam into myusername
put tWord into mypassword
put myusername && mypassword into myparameter
put "myparameter="&urlencode(myParameter) into leMessage
post leMessage to url "http://jaasnetworks.se/dbconnect.php"
put it into myResults
answer myResults
end mouseUp
please am i coding wrongly?
Your kind help will be appreciated
Happy coding to all
/Malin
I have been playing around with php webservice for livecode, but need some help/explation as i am stuck.
I want t try the login but i guess its something wrong with my code.
php code*****
// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die( "Unable to select database $dbName");
// echo "Connected to MySQL";
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
//header("location:login_success.php");
echo "Connection sucess";
}
else {
echo "Wrong Username or Password";
}
?>
livecode***
on mouseUp
put field "uname" into tNam
put field "pword" into tWord
--put tWord && tNam into field "lf"
put tNam into myusername
put tWord into mypassword
put myusername && mypassword into myparameter
put "myparameter="&urlencode(myParameter) into leMessage
post leMessage to url "http://jaasnetworks.se/dbconnect.php"
put it into myResults
answer myResults
end mouseUp
please am i coding wrongly?
Your kind help will be appreciated
Happy coding to all

/Malin