Code:
Procedure TServerSystem.CreateAccount(U: string; P: string);
var
AID:string;
begin
CurrentTIme := DateTimeToStr(Time);
SQLQuery.SQL.Text := 'SELECT * FROM Account WHERE UserID = ' + '''' + U + '''' ;
SQLQuery.ExecSQL();
SQLQuery.Active := true;
if SQLQuery.Fields[1].AsString = U then // Change Feilds value from 0 to 1
begin
log.Lines.Add('Failed to Create Account: ' + U );
log.lines.add('UserName Already in use!'); //lets test :D
end
else
begin
SQLQuery.SQL.Text := 'INSERT INTO Account (UserID, UGradeID, PGradeID, RegDate, Name, Email, RegNum, Age, Sex, ServerID) VALUES ( ' + '''' + U + '''' + ',0,0,' + '''' + CurrentTime + '''' + ',' + '''' + U + '''' +',NULL,NULL,20,NULL,0 )';
SQLQuery.ExecSQL();
SQLQuery.SQL.Text := 'SELECT AID FROM Account WHERE UserID = ' + '''' + U + '''';
SQLQuery.ExecSQL();
SQLQuery.Active := true; // this is the fix :p WORKS :D sure?, the aid should be 3 or? na look
Aid := SQLQuery.Fields[0].AsString; // Gets the AID Field :D
showmessage(AID);
sqlquery.SQL.text := 'INSERT INTO Login (UserID, AID, Password) VALUES ( ' + '''' + U + '''' + ',' + '''' + AID + '''' + ',' + '''' + P + '''' + ')';
SQLQuery.ExecSQL();
Log.Lines.Add('User account created : ' + U);
// DONE :D xD lets see if it works :Dyea
end;
end;