Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 19:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Connect autoit to sql

Discussion on Connect autoit to sql within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2013
Posts: 6
Received Thanks: 0
Connect autoit to sql

This is second question and last question.
Now I have database but How do I connect to the database.
Autoit can connect directly? or use php to login.

Now I use php to connect but I don't have knowledge about php.
can someone help me?


I want to transfer $input in autoit to check email in database but i can't understand how to do that.


And if correct user or wrong how to back to program

Help me pls it last step to complete my program.
jojo6262 is offline  
Old 05/03/2016, 16:18   #2
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
UPDATED


PHP code

Code:
<?php

$host = 'localhost';
$user = 'root';
$pass = '';
$dbase = 'test123';

$con = mysqli_connect($host, $user, $pass, $dbase);


// Check connection
if (mysqli_connect_errno()) {
   echo "Failed to connect to MySQL";
} else {


   // check is email is in a link
   if (isset($_GET['email'])) {


      // protect email from mysql injection
      $email = mysqli_real_escape_string($con, $_GET['email']);


      // cleaned data
      $email = clean_data($email);


      // get email from database
      $result = mysqli_query($con, "SELECT * FROM accounts WHERE email = '".$email."'");


     if (mysqli_num_rows($result) > 0) {
        echo 'ok';
      }


      mysqli_close($con); // close connection


   }


}


// function to clean variable to prevent xss and code injection
function clean_data($data)
{
   $invalid_characters = array("$", "%", "#", "<", ">", "|");
   $data = strip_tags($data);
   $data = trim($data);
   $data = str_replace($invalid_characters, "", $data);
   return $data;
}

?>
AutoIt code made with your example


Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#include <IE.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Send Text", 250, 162, 192, 124)
$Button1 = GUICtrlCreateButton("Send", 80, 128, 97, 25)
$Input1 = GUICtrlCreateInput("", 48, 32, 161, 21)
$Label1 = GUICtrlCreateLabel("Email", 112, 8, 23, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
		Case $Button1
			checkLogin()


  EndSwitch
WEnd


Func checkLogin()


	Local $mail = GUICtrlRead($Input1) ; read email from input
	Local $url = "http://playgame4.net/123.php?email=" ; url to check


	Local $value = _INetGetSource ($url & $mail) ; get url with data


	; check for value
	If $value == 'ok' Then
		MsgBox(0, "", "Valid email")
	Else
		MsgBox(0, "", "Invalid email")
	EndIf


EndFunc

U can test, i made 2 emails

mlukac89 is offline  
Thanks
1 User
Old 05/03/2016, 22:40   #3
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
Local $url = "http://yoursite/login.php?email= or 1==1 will work
elmarcia is offline  
Old 05/03/2016, 23:40   #4
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
On what u mean on php code ? u dont see its protected ?
mlukac89 is offline  
Old 05/04/2016, 03:01   #5
 
elite*gold: 0
Join Date: Oct 2013
Posts: 6
Received Thanks: 0
Quote:
Originally Posted by mlukac89 View Post
UPDATED


PHP code

Code:
<?php

$host = 'localhost';
$user = 'root';
$pass = '';
$dbase = 'test123';

$con = mysqli_connect($host, $user, $pass, $dbase);


// Check connection
if (mysqli_connect_errno()) {
   echo "Failed to connect to MySQL";
} else {


   // check is email is in a link
   if (isset($_GET['email'])) {


      // protect email from mysql injection
      $email = mysqli_real_escape_string($con, $_GET['email']);


      // cleaned data
      $email = clean_data($email);


      // get email from database
      $result = mysqli_query($con, "SELECT * FROM accounts WHERE email = '".$email."'");


     if (mysqli_num_rows($result) > 0) {
        echo 'ok';
      }


      mysqli_close($con); // close connection


   }


}


// function to clean variable to prevent xss and code injection
function clean_data($data)
{
   $invalid_characters = array("$", "%", "#", "<", ">", "|");
   $data = strip_tags($data);
   $data = trim($data);
   $data = str_replace($invalid_characters, "", $data);
   return $data;
}

?>
AutoIt code made with your example


Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#include <IE.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Send Text", 250, 162, 192, 124)
$Button1 = GUICtrlCreateButton("Send", 80, 128, 97, 25)
$Input1 = GUICtrlCreateInput("", 48, 32, 161, 21)
$Label1 = GUICtrlCreateLabel("Email", 112, 8, 23, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
		Case $Button1
			checkLogin()


  EndSwitch
WEnd


Func checkLogin()


	Local $mail = GUICtrlRead($Input1) ; read email from input
	Local $url = "http://playgame4.net/123.php?email=" ; url to check


	Local $value = _INetGetSource ($url & $mail) ; get url with data


	; check for value
	If $value == 'ok' Then
		MsgBox(0, "", "Valid email")
	Else
		MsgBox(0, "", "Invalid email")
	EndIf


EndFunc

U can test, i made 2 emails

oh that work but in table i have 2 colume
email and serial.
if me check email it will back to send serial to check that email and serial are correct. How to make it?

serial = drivegetserial

why i check on my link Result=invalid

i tested on free host that all in valid

Quote:
Func checkLogin()


Local $mail = GUICtrlRead($Input1) ; read email from input
Local $url = "http://neowkickclick.siam.im/check.php?email=" ; url to check


Local $value = _INetGetSource ($url & $mail) ; get url with data


; check for value
If $value == 'ok' Then
MsgBox(0, "", "Valid email")
Else
MsgBox(0, "", "Invalid email")
EndIf


EndFunc
email
jojo6262 is offline  
Old 05/04/2016, 17:40   #6
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
Then u need to change all, so what exactly that script need to do ? You can add me on skype ( mario.lukacic.or ) if u have it, or facebook so i can explain u better.
mlukac89 is offline  
Thanks
1 User
Old 05/04/2016, 20:08   #7
 
elite*gold: 0
Join Date: Oct 2013
Posts: 6
Received Thanks: 0
Quote:
Originally Posted by mlukac89 View Post
Then u need to change all, so what exactly that script need to do ? You can add me on skype ( mario.lukacic.or ) if u have it, or facebook so i can explain u better.
now i add you in facebook
jojo6262 is offline  
Old 05/06/2016, 08:12   #8
 
elite*gold: 1908
Join Date: Jan 2013
Posts: 832
Received Thanks: 629
it is not safe to use connection to dbs in script (possibility of decompiling). Use php and then send GET request to some php file(which will echo what u want). And then autoit can read that echo-ed text with:
$TextFromPHP= _INetGetSource("www.page.php")
ssamko is offline  
Old 05/06/2016, 20:37   #9
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
Quote:
Originally Posted by ssamko View Post
it is not safe to use connection to dbs in script (possibility of decompiling). Use php and then send GET request to some php file(which will echo what u want). And then autoit can read that echo-ed text with:
$TextFromPHP= _INetGetSource("www.page.php")
Did u see what i wrote ? There is nothing in autoit code on in php script on server, when u access it its like u access over normal webpage so there is no problem.
mlukac89 is offline  
Old 05/08/2016, 14:22   #10
 
elite*gold: 1908
Join Date: Jan 2013
Posts: 832
Received Thanks: 629
Quote:
Originally Posted by mlukac89 View Post
Did u see what i wrote ? There is nothing in autoit code on in php script on server, when u access it its like u access over normal webpage so there is no problem.
sorry...I didnt read your code....I wrote it in general
ssamko is offline  
Reply


Similar Threads Similar Threads
Autoit How do I connect to MySQL?
05/13/2013 - AutoIt - 3 Replies
Autoit How do I connect to MySQL? The like of which you do not. Like this Olympus Team Tutorial - YouTube Please ask for it.



All times are GMT +1. The time now is 19:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.