Jump to content

help with ie functions


t0ddie
 Share

Recommended Posts

I want to fill out a form and submit it.

this is the example given.

#include <IE.au3>

$oIE = _IECreate ("http://www.google.com")

$oForm = _IEFormGetObjByName ($oIE, "f")

$oQuery = _IEFormElementGetObjByName ($oForm, "q")

_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")

_IEFormSubmit ($oForm)

I have adjusted the code and it does not work.

#include <IE.au3>

$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php")

$oForm = _IEFormGetObjByName ($oIE, "usersname")

$oQuery = _IEFormElementGetObjByName ($oForm, "submitwrite")

_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")

_IEFormSubmit ($oForm)

what am i doing wrong?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php")
$oInput = _IEGetObjByName($oIE, "usersname")
$oButton = _IEGetObjByName($oIE, "submitwrite")
_IEFormElementSetValue ($oInput, "AutoIt IE.au3")
_IEAction($oButton, "click")

The website is badly made, incorrect by web standard as form should have an ID or name.

Edited by Steveiwonder

They call me MrRegExpMan

Link to comment
Share on other sites

$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php")
$oInput = _IEGetObjByName($oIE, "usersname")
$oButton = _IEGetObjByName($oIE, "submitwrite")
_IEFormElementSetValue ($oInput, "AutoIt IE.au3")
_IEAction($oButton, "click")

#include <IE.au3>

$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php",0,0)

$oInput = _IEGetObjByName($oIE, "usersname")

$oButton = _IEGetObjByName($oIE, "submitwrite")

_IEFormElementSetValue ($oInput, "test2")

_IEAction($oButton, "click")

ok this works but not when hidden. I want this process to be hidden.

is there any workaround? also I would rather not have to click if possible.

EDIT: i can change the code in the site i just dont know what to change it to

the form is a free template i found online.

I just want to make a simple form that logs what users submit into a text file on my server. and i want to be able to use autoit to automate it.

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

if the form is a free template and you can edit it then make the first like look like this.

<form method="POST" action="" name="form1" id="form1">
Name: <input type="text" name="usersname"/><br/>
<input type="submit" value="Write" name="submitwrite"/>
</form>

and your script like this

$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php")
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oInput = _IEFormElementGetObjByName ($oForm, "usersname")
_IEFormElementSetValue ($oInput, "AutoIt IE.au3")
_IEFormSubmit($oForm)
Edited by Steveiwonder

They call me MrRegExpMan

Link to comment
Share on other sites

#include <IE.au3>

$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php")

$oForm = _IEFormGetObjByName ($oIE, "form1")

$oInput = _IEFormElementGetObjByName ($oForm, "usersname")

_IEFormElementSetValue ($oInput, "the best test ever")

_IEFormSubmit($oForm)

i had to adjust it you put the wrong name in the field but it still does not work

:mellow:

I adjusted the source code on the page

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

#include <ie.au3>
$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php")
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oInput = _IEFormElementGetObjByName ($oForm, "usersname")
_IEFormElementSetValue ($oInput, "AutoIt IE.au3")
Msgbox(0, "Press ok", "See the value?, press ok to submit")
_IEFormSubmit($oForm)

Dude, it works. Your website doesn't.

Your form has no action there for when you submit the page it will not go anywhere... if your new to web development then i suggest you look up using php with forms etc.

Your form should look like this

<form method="POST" action="ThisPageReceievesUserInput.php" name="form1" id="form1">

and the php on "ThisPageReceievesUserInput.php" like this

<?php

$usersname = $_POST['usersname'];

echo $usersname;

?>
Edited by Steveiwonder

They call me MrRegExpMan

Link to comment
Share on other sites

EDIT: the form works manually so it must be the autoit script.

there is an action its just that you cannot see it for some reason when you view source some of the code does not appear. the php code is on the same page as the form.

I am not sure exactly what to mess with.

here is the ENTIRE php code for the form.

this is the true source of test.php

<?php
        // Check if the user submitted this form
        if (isset($_POST["submitwrite"])) {
                // Open the file in write mode
                $handle = fopen("writetest.txt","a+"); 
                
                // If successful
                if ($handle) {
                        // Write to that handle the username submitted in the form and the date
                        fwrite($handle,$_POST["usersname"] . " - " . date("Y-m-d"));
                        
                        // Close the file
                        fclose($handle);
                }
        }
?>
                

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Submit example</title>
</head>
<body>

<!-- Notice how the form is submitting to itself -->
<form method="POST" action="<?php $_SERVER["PHP_SELF"]; ?>" name="form1" id="form1">
Name: <input type="text" name="usersname"/><br/>
<input type="submit" value="Write" name="submitwrite"/>
</form>

</body>

</html>
Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

your example did not work that is what I am trying to tell you.

also in your example you used the wrong name

I replaced this line on test.php

<form method="POST" action="<?php $_SERVER["PHP_SELF"]; ?>" name="form1" id="form1">

with this

<form method="POST" action="test.php" name="form1" id="form1">

still does not work.

now using my original php code, without using autoit, if i manually type something in the form then click the submit button, it works. there is a text file created on my server and the input from the form has been written to it.

now with your script

#include <ie.au3> 
$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php") 
$oForm = _IEFormGetObjByName ($oIE, "form1") 
$oInput = _IEFormElementGetObjByName ($oForm, "usersname") 
_IEFormElementSetValue ($oInput, "teeeeeeest")
_IEFormSubmit($oForm)

it enters the data into the form and you can hear a clicking sound and the data dissappears and it LOOKS like is submits but nothing is submitted. and if i test it out manually it DOES submit.

do i need to name the button on the php script too?

name="form2" id="form2"

it could be that your script is fine but my webpage works manually and does not work with the script.

so maybe nothing is wrong with your script, but it still does not work on my page.

maybe the php code needs some adjustment.

if you type something into that form i can tell you what it is so I know its working just not with your script.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Can you add an output on the page so i can test please, just echo the input.

I have no idea what I am doing when it comes to php

but this should be sufficient

http://www.diablouniverse.com/Grab/writetest.txt

just go there after submit and you should see it.

also how do you add a carriage return in php?

i am trying to append everything vertically not horizontally as you can see it is doing.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

<?php
        // Check if the user submitted this form
        if (isset($_POST["submitwrite"])) {
 echo $_POST['usersname'];
                // Open the file in write mode
                $handle = fopen("writetest.txt","a+"); 
                
                // If successful
                if ($handle) {
                        // Write to that handle the username submitted in the form and the date
                        fwrite($handle,$_POST["usersname"] . " - " . date("Y-m-d"));
                        
                        // Close the file
                        fclose($handle);
                }
        }
?>

add that line echo $_POST['usersname'];

They call me MrRegExpMan

Link to comment
Share on other sites

<?php
        // Check if the user submitted this form
        if (isset($_POST["submitwrite"])) {
 echo $_POST['usersname'];
                // Open the file in write mode
                $handle = fopen("writetest.txt","a+"); 
                
                // If successful
                if ($handle) {
                        // Write to that handle the username submitted in the form and the date
                        fwrite($handle,$_POST["usersname"] . " - " . date("Y-m-d"));
                        
                        // Close the file
                        fclose($handle);
                }
        }
?>

add that line echo $_POST['usersname'];

line added. thanks for helping me troubleshoot this.

I will let you toy with it and I hope you can find a solution!

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Ok i know whats wrong.

Your form HTML is wrong.

Change

<form method="POST" action="<?php $_SERVER["PHP_SELF"]; ?>" name="form1" id="form1">

To:

<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>" name="form1" id="form1">

Then try to use my script.

#include <ie.au3>
$oIE = _IECreate ("http://www.diablouniverse.com/Grab/test.php", 0, 0)
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oInput = _IEFormElementGetObjByName ($oForm, "usersname")
_IEFormElementSetValue ($oInput, "THIS SCRIPT WORKS FINE")
_IEFormSubmit($oForm)

They call me MrRegExpMan

Link to comment
Share on other sites

nope

changing to single quotes did not effect it.

also notice how the php echo works when you type data in manually

but does not work when you use script.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Ok well i can gaurentee that the reason why your _ieformsubmit doesnt work is due to your action="" being empty i'm 100% sure this it why. Just add action="test.php" your action should never be empty as "submit" will need someone to go.

Change it and test. The script would work fine if i adapted it for my website. see my code @ www.falcubar.co.uk check the HTML of the login form.

p.s. don't try and register or your acc will be deleted.

Edited by Steveiwonder

They call me MrRegExpMan

Link to comment
Share on other sites

This is what you see when you click "view source" on the form when visiting from the url.

<!-- Notice how the form is submitting to itself -->

<form method="POST" action="" name="form1" id="form1">
Name: <input type="text" name="usersname"/><br/>
<input type="submit" value="Write" name="submitwrite"/>

</form>

this is what you see when you actually edit test.php on your webserver.

<!-- Notice how the form is submitting to itself -->

<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>" name="form1" id="form1">
Name: <input type="text" name="usersname"/><br/>
<input type="submit" value="Write" name="submitwrite"/>
</form>

as noted in one of my posts above, the action field is not empty.

for some reason it just shows up that way when you view the page source from a browser.

I looked at your source code on your site but I do not know how to apply it to what I am trying to do.

Since you have your own server you can test this script out yourself if you would like.

I do not need this exact php script if there is no way it can work I just need a script that works the way this script works by logging the input to a text file.

here is test.php once again

<?php
        // Check if the user submitted this form
        if (isset($_POST["submitwrite"])) {
 echo $_POST['usersname'];
                // Open the file in write mode
                $handle = fopen("writetest.txt","a+"); 
                
                // If successful
                if ($handle) {
                        // Write to that handle the username submitted in the form and the date
                        fwrite($handle,$_POST["usersname"] . " - " . date("Y-m-d"));
                        
                        // Close the file
                        fclose($handle);
                }
        }
?>
                

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Submit example</title>
</head>
<body>

<!-- Notice how the form is submitting to itself -->

<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>" name="form1" id="form1">
Name: <input type="text" name="usersname"/><br/>
<input type="submit" value="Write" name="submitwrite"/>
</form>

</body>

</html>

if you know of some other script that will work instead of this one then let me know lol

and also least important but still important is that I want to add a carriage return to the end of each append

so that new entries are on a new line and not all on one line.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

PHP is server side of course i won't see it. BUT my point is <?php $_SERVER['PHP_SELF']; ?> should be outputting "test.php" but it isnt. MANUALLY CHANGE IT AND TRY AGAIN.

Here is a quote from

http://www.php.net/manual/en/reserved.variables.server.php

'PHP_SELF'

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.

Your version of PHP may not support PHP_SELF

Edited by Steveiwonder

They call me MrRegExpMan

Link to comment
Share on other sites

I know i checked this already but just to doublecheck i tried again.

as i posted before, changing this does nothing.

<?php
        // Check if the user submitted this form
        if (isset($_POST["submitwrite"])) {
 echo $_POST['usersname'];
                // Open the file in write mode
                $handle = fopen("writetest.txt","a+"); 
                
                // If successful
                if ($handle) {
                        // Write to that handle the username submitted in the form and the date
                        fwrite($handle,$_POST["usersname"] . " - " . date("Y-m-d"));
                        
                        // Close the file
                        fclose($handle);
                }
        }
?>
                

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Submit example</title>
</head>
<body>

<!-- Notice how the form is submitting to itself -->

<form method="POST" action="test.php" name="form1" id="form1">
Name: <input type="text" name="usersname"/><br/>
<input type="submit" value="Write" name="submitwrite"/>
</form>

</body>

</html>

as you can see I have adjusted the code. perhaps there is something else I must also adjust in the code?

this is the way the code is on my server right now.

if you navigate to the test page http://www.diablouniverse.com/Grab/test.php

you will notice that when you enter text manually, it gives you an echo

when you try the script, it does not echo.

something is still wrong lol.

thanks for bearing with me :mellow:

EDIT: just wanted to say also that if the script works manually then my version of php must support php_self but at the same time it does not show up in the source but i do not get any kind of error using it, its just when you view the source it looks empty. maybe that is just a side effect of sending a script to itself. I also tried the full path to the test.php in the action by typing http://www.diablouniverse.com/Grab/test.php and that did not work, and I also tried putting the action target in single quotes instead of double and it did not work either. I mean they do work all those ways manually though... lol. just not with the script.

there has to be something else wrong with the php somewhere... or maybe it wont work as one file? maybe i need to make a second seperate php file?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

omfg i got it.

PHP Code issue

<?php
        // Check if the user submitted this form
        if (isset($_POST["usersname"])) {
 
                // Open the file in write mode
                $handle = fopen("writetest.txt","a+"); 
                
                // If successful
                if ($handle) {
                        // Write to that handle the username submitted in the form and the date
                        fwrite($handle,$_POST["usersname"] . " - " . date("Y-m-d"));
                        
                        // Close the file
                        fclose($handle);
                }
        }
?>

The code was looking to see if the FORM was submitted (button pressed) _IEFormSubmit does not click the button your IF statement was checking to see if button was set but it isn't.

I've changed your PHP to check if the input field is set not the submit button

Edited by Steveiwonder

They call me MrRegExpMan

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...