Jump to content




Login using PHP

computer networking help

  • You cannot reply to this topic
23 replies to this topic

#1 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 15 May 2013 - 10:15 PM

Alright, my buddies from school and I have created a private ComputerCraft server on his computer and he is hosting a website from it. Instead of having a password server in game, I want to use MySQL. I know this could be very, very dangerous, but we've been able to block any other IP's coming into the web server to ensure the safety of the passwords. I want to be able to make a PHP script that handles the ComputerCraft input, and relays it to the MySQL server, and it get's feedback, and sends the feedback back to the computer ingame. Could someone help? How could this be accomplished?

Edited by 1vannn, 15 May 2013 - 10:16 PM.


#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 15 May 2013 - 10:27 PM

I can help. Fairly easy.

Give me a few more details as to how CC will send / receive the info.

Going to sleep now so will reply later :P

#3 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 15 May 2013 - 11:13 PM

1. Write("Username: ")
2. Send to server
3. CC expects a reply

#4 JackCarterSmith

  • Members
  • 68 posts
  • LocationTrain factory

Posted 15 May 2013 - 11:53 PM

Here I have the solution for you: my OS! Viewing the source code of the API Nexos, doLogin() function

Good Luck!

EDIT: If you have any questions do not hesitate

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 16 May 2013 - 08:14 AM

View Post1vannn, on 15 May 2013 - 11:13 PM, said:

1. Write("Username: ")
2. Send to server
3. CC expects a reply

Just send the username?
What must be returned back?

View PostNexus, on 15 May 2013 - 11:53 PM, said:

Here I have the solution for you: my OS! Viewing the source code of the API Nexos, doLogin() function

Good Luck!

EDIT: If you have any questions do not hesitate

He's wanting the php code too.

#6 LNETeam

  • Members
  • 111 posts
  • LocationEclipse

Posted 16 May 2013 - 11:54 AM

First and foremost, are you proposing using some type of hashing, when sending traffic to and from the server. This would mainly we done with passwords, which I'm not sure (by what you specified) you are going to incorporate. I can write your PHP code, send it to you and fill in the rest of mandatory variables. Just let me know :)

#7 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 16 May 2013 - 03:20 PM

View PostremiX, on 16 May 2013 - 08:14 AM, said:

View Post1vannn, on 15 May 2013 - 11:13 PM, said:

1. Write("Username: ")
2. Send to server
3. CC expects a reply

Just send the username?
What must be returned back?

View PostNexus, on 15 May 2013 - 11:53 PM, said:

Here I have the solution for you: my OS! Viewing the source code of the API Nexos, doLogin() function

Good Luck!

EDIT: If you have any questions do not hesitate

He's wanting the php code too.
If the user does not exist in the database, it'll immediately return an error.

#8 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 16 May 2013 - 03:33 PM

View PostLNETeam, on 16 May 2013 - 11:54 AM, said:

First and foremost, are you proposing using some type of hashing, when sending traffic to and from the server. This would mainly we done with passwords, which I'm not sure (by what you specified) you are going to incorporate. I can write your PHP code, send it to you and fill in the rest of mandatory variables. Just let me know :)
I'm looking for more of a small tutorial, so then I can work on the rest on my own. :)

#9 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 16 May 2013 - 04:38 PM

View Post1vannn, on 16 May 2013 - 03:20 PM, said:

View PostremiX, on 16 May 2013 - 08:14 AM, said:

--snip
If the user does not exist in the database, it'll immediately return an error.

LUA:
Spoiler

PHP:
Spoiler

Untested.. tell me if there are any errors :)

#10 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 16 May 2013 - 05:48 PM

Yup, the script works. Posted Image
Howdo I remove the code at the bottom?

Edit: Solved. http://members.000we...m/analytics.php

Edited by 1vannn, 16 May 2013 - 06:07 PM.


#11 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 16 May 2013 - 06:12 PM

Can you help with a registration system please? I'm honestly clueless about this.

#12 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 17 May 2013 - 12:31 AM

Never knew you could do that on webhost :o haha

Registration uses the insert query.
Note: You will need to add some anti-spam method to prevent spam of multiple users being created

LUA:
Spoiler

PHP:

Spoiler

Shout if there are any errors

#13 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 17 May 2013 - 04:41 PM

It will not work due to the script not sending the PHP variable correctly. Not sure how to fix it, I've been fiddling around for an hour or so.

#14 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 17 May 2013 - 05:18 PM

I've tracked it down to your if statement, now, the problem is that your thingy does not like my MySQL. How might I fix this issue?

#15 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 18 May 2013 - 08:48 AM

Thingy does not like MySQL? What do you mean? What is it doing?

#16 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 18 May 2013 - 09:26 AM

It's skipping everything and just saying the user exists.

#17 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 18 May 2013 - 07:22 PM

What? it doesn't re-add the user if the user already exists.

#18 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 18 May 2013 - 11:00 PM

I checked the database, there is nothing in the database, and its still saying the user exists.

#19 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 18 May 2013 - 11:25 PM

Oh woops, change
if (!$result || mysql_num_rows($result) == 0) {
to
if ($result and mysql_num_rows($result) > 0) {


#20 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 19 May 2013 - 12:33 AM

It's 1:30AM for me, I'll try it in the morning.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users