Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-13-2011, 07:18 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
SQL Problem

I am probably doing this horribly wrong, but I am really new to SQL and would appreciate ANY advice given.
Basically my aim is to make a login box.
I have made it, it works. BUT It only allows you to login to the LAST created Account and Password Row, it seems all others are ignored.
Here is the GUI I am using to login.

PHP Code:
findplayer("Graal780374").addweapon(name);
function 
onActionServerSide(){
if(
params[0] == "Login"){
temp.req requestsql("SELECT * FROM Accounts"true);
for (
temp.rowtemp.req.rows)
if(
params[1] == temp.row.Account && params[2] == temp.row.Password){
player.chat "Sucessful Username Entered!";
}else{
player.chat "Failed Login!";
}
}
}
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("Login_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "154,124";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove false;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
= (screenwidth/2) - (width/2);
    
= (screenheight/2) - (height/2);
    
alpha 1;

    new 
GuiTextCtrl("Login_Text") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Login";
      
width 32;
      
58;
      
5;
    }
    new 
GuiTextCtrl("Account_Text") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Account";
      
width 48;
      
6;
      
35;
    }
    new 
GuiTextCtrl("Password_Text") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Password";
      
width 57;
      
6;
      
60;
    }
    new 
GuiTextEditCtrl("Account_TextEdit") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
69;
      
36;
      
text "";
    }
    new 
GuiTextEditCtrl("Password_TextEdit") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
69;
      
61;
      
text "";
    }
    new 
GuiButtonCtrl("Login_Button") {
      
profile GuiBlueButtonProfile;
      
text "Login";
      
width 55;
      
height 25;
      
100;
      
100;
    }
    new 
GuiButtonCtrl("Register_Button") {
      
profile GuiBlueButtonProfile;
      
text "Register";
      
width 55;
      
height 25;
      
100;
      
= -1;
    }
  }
}

function 
Login_Button.onAction() {
triggerserver("weapon"this.name"Login"Account_TextEdit.textPassword_TextEdit.text);

And here is what i am doing to create the tables, which DOES work.

PHP Code:
requestsql("CREATE TABLE Accounts (Account varchar not null default '' primary key, Password int not null default 1)"false);

requestsql("INSERT INTO Accounts VALUES ('Account', 'Password')"false);
requestsql("INSERT INTO Accounts VALUES ('Account2', 'Password2')"false);

temp.req requestsql("SELECT * FROM Accounts"true);
if (!
temp.req.completed)
  
waitfor(temp.req,"onReceiveData",60);
  
echo(
"Accounts in database: " temp.req.rows.size());
for (
temp.rowtemp.req.rows)
echo(
"SQL:   "@temp.row.Account@"   "@temp.row.Password); 
As I stated i am probably doing it extremely wrong.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.