The Daily Click ::. Forums ::. Klik Coding Help ::. ..sql?
 

Post Reply  Post Oekaki 
 

Posted By Message

ZeroFun



Registered
  08/06/2010
Points
  4
8th June, 2010 at 09:31:09 -

Hello, im wondering..
..can you use SQL for password and username login? if you can. how?
also i would need (when player logins) to get string from database (Wich contains information like what he has unlocked etc what rank (i would string parse it))
thx in advance :3

 
"How'd i type it so that you guys can see it?" -- idiots@irc

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
8th June, 2010 at 10:14:31 -

You can't just access an SQL database from MMF. You have to access a script URL that accesses the SQL database.

Here's an example of how to access a mysql database with php.


<?php
//create a connection to a mysql server
$con = mysql_connect($host,$user,$password);

//kill the script if no connection could be made
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

//select a database on the created connection
mysql_select_db($database, $con);

//Do mysql stuff here

//close the mysql connection after you are finished
mysql_close($con);
?>


Then you would upload this to your host (the same host that has your mysql databases) and use the GET Object in mmf to request this script. The GET Object returns you the page content of the URL.

I think you are underestimating the complexity of doing what you want to do. You will have to understand HTTP requests, understand SQL/MySQL and SQL/MySQL Queries, be able to code php scripts, have a host that allows php scripts and gives you access to SQL/MySQL databases, and know how to set up the databases and tables etc.

I would recommend:
-Finding a free host that supports php and grants you MySQL databases.
-Learning how to setup a mysql database, creating tables, inserting entries, updating entries, deleting entries, etc.
-Learning PHP.
-Learning how to do MySQL in PHP.

you can find a lot of help with php and mysql here:
http://w3schools.com/php/default.asp

 
n/a

ZeroFun



Registered
  08/06/2010
Points
  4
8th June, 2010 at 14:20:47 -

Nvm, i got friend of mine do the code and i found the object
now, howd i use it?

Edited by ZeroFun

 
"How'd i type it so that you guys can see it?" -- idiots@irc

nick_peoples



Registered
  10/12/2009
Points
  173

I am an April Fool
8th June, 2010 at 20:22:41 -

where can i find a free host? i cant seem to find one

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
9th June, 2010 at 00:06:06 -

depending on whether you are going to use GET or POST it would work differently.

in a GET request you would request the specified script.

GET http://www.myhost.com/myphpscript.php 


in addition to this you would also send the url script some parameterized values like the login name and password (you might want to send the password encrypted otherwise it would be VERY unsafe)

GET http://www.myhost.com/myphpscript.php?loginname=robotcecil&loginpassword=ry562s1e1949ffs389289dawe0328907 


in that last snippet '?' denotes the start of the parameter list, '=' denotes that the following is the VALUE of the preceding parameter, and '&' separates each parameter/value pair.

so i have parameter 'loginname' which has a value of 'robotcecil'
and i have a second parameter 'loginpassword' with a value of 'ry562s1e1949ffs389289dawe0328907' which is an arbitrary value to show you what an encrypted password might look like (32bit hash using md5. there are a couple of extensions that do md5 hashing. one of them is only available to mmf2dev owners. the other is string parser 2).

your php script would then go like this.

<?php
//create a connection to a mysql server
$con = mysql_connect($host,$user,$password);

//kill the script if no connection could be made
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

//select a database on the created connection
mysql_select_db($database, $con);

//Do a mysql query into the table where you store your user information (login name, password, user stats, etc)
//and look for the user with the login name (these should be forced to be unique upon creation so that lookup queries
//will only return ONE result) that matches the sent $_GET['loginname'] value from the HTTP GET Request by mmf2.
//This will return all the cell information about the resulting sql entry (login name, password, user stats, etc)
//which you can use.
//You can then compare the MD5 hash of the sent $_GET['loginpassword'] with the MD5 of the resulting sql entry.
//If they match you can print out the users stats, etc for mmf2 to recieve and parse and use in-game.
//If they do NOT match you can send a status string like "login failed" for mmf2 to detect and act
//accordingly.

//Close mysql connection
mysql_close($con);
?>


Edited by Cecilectomy

 
n/a

nick_peoples



Registered
  10/12/2009
Points
  173

I am an April Fool
9th June, 2010 at 00:18:19 -

i hate to be a pain, but i didnt really understand that
Normally i would just assume its too dificult but i realy need it for a project
do you know of anay good Exaples?

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
9th June, 2010 at 13:17:56 -

over at http://www.gamebuilder.info/ we have a highscore board system that uses php scripts and the GET Object.
If you have an account you can download our template.zip under your "My Score Boards" page. This zip archive has mfa templates that are commented and may give you a better understanding at how to use the GET Object. Also with an account you will have access to the use of our scoreboard systems.

 
n/a

nick_peoples



Registered
  10/12/2009
Points
  173

I am an April Fool
9th June, 2010 at 20:37:39 -

thanks, i found a perfect tutorial!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click