Sign in to follow this  
Followers 0
Potarski

WinHttp Error

14 posts in this topic

#1 ·  Posted (edited)

Hello, i made script for my website , add news but it POST delete and send news and close my news :)

I don't know why?

Global $sAddress = "localhost"
Global $sPage = "admindex?id=1"
Global $sPage2 = "newspanel/"

Local $hOpen = _WinHttpOpen()
Local $hConnect = _WinHttpConnect($hOpen, $sAddress)
Local $hConnect2 = _WinHttpConnect($hOpen, $sAddress2)

$1 = _WinHttpSimpleFormFill($hConnect, $sPage, Default, "name:login", "admin", "name:password", "adminpw")
_WinHttpCloseHandle($1)
    $2 = _WinHttpSimpleFormFill($hConnect2, $sPage, Default, "name:useMake", "true") ;
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hConnect2)
    _WinHttpCloseHandle($hOpen)

In html is 3 from actions:

<form action='/newspanel/' method='post'>

    <input type='hidden' name='useDelete' value='1'>
    <input type='submit' value='Delete news' class='formSubmit' title='Delete this news ...ęą'>
                        </form>
            
            <form action='/newspanel/' method='post'>
            <input type='hidden' name='useMake' value='true'>
            <input type='submit' value='Write news' class='formSubmit' title='Write news ...ęą'>
                        </form>
                
                        <form action='/newspanel/' method='post'>
                        <input type='hidden' name='useClose' value='1'>
                        <input type='submit' value='Close news' class='formSubmit' title='Close news ...ęą'>
                    </form>

It login but use all froms for one post O.o

Edited by Potarski

Share this post


Link to post
Share on other sites



Nobody help me? ;p

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I would suggest looking at the FAQ >> http://www.autoitscript.com/wiki/FAQ#When_should_I_bump_my_threads first.

Your first problem why the code above won't work is you are missing #include <WinHttp.au3>.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I give piece of code, i have include on top script but you dont know what i need.

My problem is, i make value for one submit post but my script post all forms.

Read carefully.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OK, try this first >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; ##### NOT TESTED #####

#include "WinHttp.au3"

Global $sAddress = "localhost"
Global $sPage = "admindex?id=1"

Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, $sAddress)

$sRead = _WinHttpSimpleFormFill($hConnect, $sPage, Default, "name:login", "admin", "name:password", "adminpw") ; Make sure your HTML File has an Input called Login & Password!
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

If $sRead Then
    MsgBox(64, "Complete", "Success!")
EndIf
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I said, login in my script working, i use ConsoleWrite and it give me good html code after login in, probles is in second POST. But i don't know why.

Share this post


Link to post
Share on other sites

If you don' specify the form to use, _WinHttpSimpleFormFill will use the first form that was found.


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Look this:

I declared my form.

_WinHttpSimpleFormFill($hConnect2, $sPage, Default, "name:useMake", "true") ;

<form action='/newspanel/' method='post'>
            <input type='hidden' name='useMake' value='true'>
            <input type='submit' value='Write news' class='formSubmit' title='Write news ...ęą'>

Why it use all forms in HTML?

Forms:

<form action='/newspanel/' method='post'>

    <input type='hidden' name='useDelete' value='1'>
    <input type='submit' value='Delete news' class='formSubmit' title='Delete this news ...ęą'>
                        </form>
            
            <form action='/newspanel/' method='post'>
            <input type='hidden' name='useMake' value='true'>
            <input type='submit' value='Write news' class='formSubmit' title='Write news ...ęą'>
                        </form>
                
                        <form action='/newspanel/' method='post'>
                        <input type='hidden' name='useClose' value='1'>
                        <input type='submit' value='Close news' class='formSubmit' title='Close news ...ęą'>
                    </form>
Edited by Potarski

Share this post


Link to post
Share on other sites

You did NOT specify the form. Choosing the form is done with the third parameter. Since the form has no ID or name, you have to use its index.

What you have done is setting the value of a formfield. Since this field does not exist in the form, just the plain delete-form wihtout modifications will be sent since this is the first form on the page.


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

So I can't fix it?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

You have to find the index of the form you want to send and use it instead of Default.

_...FormFill(PARAM, PARAM, "index:_INDEX_HERE_", ...)
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

So, can you show me how?

In one index are 3 same forms.

Good line?

_WinHttpSimpleFormFill($hConnect2, "index:name:useMake", "name:useMake", "true") ;
Edited by Potarski

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Not index as in an indexfile, but index as in a number assigned to the form.

Start at the beginning of the sourcecode. The first <form> has index 0, the second index 1 ,...

_WinHttpSimpleFormFill($hConnect2, $sPage, "index:0") ;

or

_WinHttpSimpleFormFill($hConnect2, $sPage, "index:1") ;

or

_WinHttpSimpleFormFill($hConnect2, $sPage, "index:2") ;

...

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

You're awesome thanks you so much !

Share this post


Link to post
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
Sign in to follow this  
Followers 0