Jump to content

Just "read" a simple response from php


Recommended Posts

Hello, I currently have a autoit application working, at some point I need it to access a .php on my website that will check some values at Mysql. If the values are OK than I need the php to pass this OK to the autoit, so the process can continue.. if not ok, the process will stop. Can anybody please help me? I`m new to autoit, I`m being reading tons of topics but all them seems to doing much more than I need, like download or uploading files or filling forms.. All I need is the OK response from PHP into the AUTOIT application...

It would be really great if someone helpe me!! Thank you very much

Link to comment
Share on other sites

Your question is vague, so I give you a simple example.

Make a file called in the webserver called "autoit-api.php". Put code in it something like this:

$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
    die('Invalid query: ' . mysql_error());
} else {
    echo $result;
}

The idea is that you will use this file to retrieve the data from the database, and just print it. Don't add any HTML. Print just the value.

Also make an AutoIt script on your own computer and call it "retrieve php value.au3" or similar. Put in it a code like this:

#include <INet.au3>
$value = _INetGetSource ( "http://www.mywebsite.com/autoit-api.php" )
MsgBox(0, "The value is:", $value)

Then AutoIt will make a message box with the value that he got from the php script.

Also: http://stackoverflow.com/questions/7056368/read-variables-from-browser-php-or-xml

Link to comment
Share on other sites

Thank you this really work like a charm! I did some changes for my application and everything is working!

Also, how can I do the reverse? Send variables from autoit to PHP ? is that possible using the sabe _InetGetSource ? how could I send the a POST method together ?

Link to comment
Share on other sites

If you use GET messages, you can use InetRead() or _INetGetSource() and add the variables to the URL:

"http:/mywebsie.com/autoit-api.php?var1=1&var2=22&var3=33&nothing=0"

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

THanks for quick response.. Though that was a little too much for me LOL .. I`m pretty new to autoit and php it`s been pretty much a challenge. Anyway. this is my autoit code right now:

<autoit>

#include <INet.au3>

$INPUT_USERNAME = "popo"

$INPUT_PASSWORD = "007"

_InetGetSource("http://mysite.com/PHPTEST/dbcheckTESTE.php?username=" & $INPUT_NAME & "&password=" & $INPUT_PASSWORD)

</autoit>

I have no idea if the way I`m using will work. and if this is the correct syntax for the InetGetSource ... so in the oder hand my php that should receive this variables is like this:

<?php

//Getting from app

$username = $_POST['username'];

$password = $_POST['password'];

$result = mysql_query("INSERT INTO testeuser (username, pw) VALUES('$username', '$password' )") or die('Query failed: ' . mysql_error());

So please help!

Link to comment
Share on other sites

Well, if you're using the URL you'll need to use the $_GET[] array in PHP or it will not work.

Perhaps somebody else from the Forum has some ideas on how to send POST variables.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Do I need to use the GET function ? I thought if I use the POST i can also use the post to read the variables .. I run a example using 2 php files that pass variables to each other using only post. So I guess it should be the same, but intead AUTOIT to php using post .

Am I missing something?

Thank you

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...