• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

login chandoo using credentials

YasserKhalil

Well-Known Member
Hello everyone
I have devised a code using IE to login chandoo
Code:
Sub Login_Chandoo_Forum_Using_Internet_Explorer()
    Dim ie          As Object
    Dim e          As Object

    Set ie = CreateObject("InternetExplorer.Application")

    With ie
        .Visible = True
        .navigate "https://chandoo.org/forum/login/"
Previous:
        Application.Wait Now() + TimeValue("00:00:03")

        On Error GoTo Previous
        .document.getElementById("ctrl_pageLogin_login").Value = "myemail@gmail.com"
        .document.getElementById("ctrl_pageLogin_password").Value = "mypassword"
        For Each e In .document.getElementsByTagName("input")

            If e.Value Like "Log in" And e.Type = "submit" Then
                e.Click: Exit For
            End If
        Next e
    End With
End Sub

It is working well ..

I need a way to login the website using xml with credentials ... something like that
Code:
Sub httpclient()
    Dim xmlhttp As New MSXML2.xmlhttp, myurl As String
    myurl = "https://chandoo.org/forum/login/"
    xmlhttp.Open "POST", myurl, False
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send "credtentials here"
    MsgBox (xmlhttp.responseText)
End Sub
 
Try the below code:
Code:
Sub Log_In()
    Dim HTTP As New XMLHTTP60, HTML As New HTMLDocument
    Dim post As Object, uname As String, pword As String
    Dim postdata As String
 
    uname = "your_username"                        ''put your username here
    uname = Application.EncodeURL(uname)
    pword = "your_password"                          ''put your password here
    pword = Application.EncodeURL(pword)
 
    postdata = "login=" & uname & "&register=0&password=" & pword & "&cookie_check=1&redirect=%2Fforum%2Fthreads%2Flogin-chandoo-using-credentials.37299%2F&_xfToken="
 
    With HTTP
        .Open "POST", "https://chandoo.org/forum/login/login", False
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        .setRequestHeader "User-Agent", "Mozilla/5.0"
        .send postdata
        HTML.body.innerHTML = .responseText
    End With

    Set post = HTML.getElementsByClassName("titleBar")(0).getElementsByTagName("h1")(0)
    MsgBox post.innerText
End Sub

The macro will get you logged in and fetch you the TITLE of this post. It will automatically lead you to this page when the log in process is done.
 
Last edited:
After studying your code I think the postdata line should be
Code:
postdata = "login=" & uname & "&register=0&password=" & pword & "&cookie_check=1&redirect=%2Fforum%2F&_xfToken="
 
After logging in, if your intention is to stay elsewhere, then you need to change that portion. Btw, you don't need to change anything manually. What is dev tool for?
 
Thank you very much for great help...

A question : Suppose there is a search box after logging in specific site and I would like to use that search box and click the icon next to it
Will this method allow that?
 
This method should not work for another site unless the both sites are identically structured (that is less likely possible). Every method should be individual when it is about "POST" request.
 
It is not for another site .. It is for the same site but another webpage inside that side.. the first one will be for entering the credentials and the after logging there will be the second page with "Search" box
 
In that case, I'm afraid, you need to go for another "GET" request. Not sure, though. At least, not before experiment.
 
Last edited:
Back
Top