Potarski Posted February 24, 2011 Share Posted February 24, 2011 (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 February 24, 2011 by Potarski Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 Nobody help me? ;p Link to comment Share on other sites More sharing options...
guinness Posted February 24, 2011 Share Posted February 24, 2011 (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 February 24, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 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. Link to comment Share on other sites More sharing options...
guinness Posted February 24, 2011 Share Posted February 24, 2011 (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 February 24, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 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. Link to comment Share on other sites More sharing options...
ProgAndy Posted February 24, 2011 Share Posted February 24, 2011 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 Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 (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 February 24, 2011 by Potarski Link to comment Share on other sites More sharing options...
ProgAndy Posted February 24, 2011 Share Posted February 24, 2011 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 Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 So I can't fix it? Link to comment Share on other sites More sharing options...
ProgAndy Posted February 24, 2011 Share Posted February 24, 2011 (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 February 24, 2011 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 Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 (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 February 24, 2011 by Potarski Link to comment Share on other sites More sharing options...
ProgAndy Posted February 24, 2011 Share Posted February 24, 2011 (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 February 24, 2011 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 Link to comment Share on other sites More sharing options...
Potarski Posted February 24, 2011 Author Share Posted February 24, 2011 You're awesome thanks you so much ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now