1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Ajax forms

Discussion in 'C, C++, C#' started by Ceg3xow, Jul 10, 2011.

  1. Ceg3xow

    Ceg3xow Newbie

    Joined:
    Jul 6, 2011
    Messages:
    18
    Likes Received:
    1
    Hi, i'm building a bot in php, i know it's bad and I should move to another language but i'm just making my first bot to get experience at it, this bot goes into a forum I chose to target, downloads a random topic, get it's title and answer it automatically, I made all that because it was easy html forms and html parsing, easy stuff, but I don't get how I can post, can someone help me ?

    this is the new message form:
    Code:
    <textarea name="message" id="messageContent" rows="18" wrap="virtual" tabindex="2"></textarea>
    
    <div class="left formSend-content">
    </span>
    <span class="format-option-last">
    <img src="">&nbsp;
    <a href="javascript:bbstyle(-1, 'post', 'messageContent', 'addbbcode')" 
    id="closemarks">FECHAR MARCAS</a>
    </span>
    <br>
    <textarea name="message" id="messageContent" rows="18" wrap="virtual" tabindex="2"></textarea>
    </div>
    
    
    <div class="right formSend-send">
    <span id="formSubmit">
    <a href="#" class="formSubmit" tabindex="3"></a>
    </span>
    </div>
    and this is the fucntion I tracked on view source:

    Code:
    	//Enviar formulário de nova mensagem
    	$(".formSubmit").click(function(e){
    		e.preventDefault();
    		e.stopPropagation();	
    		if ($("#messageContent").attr("value") == undefined || $("#messageContent").attr("value").length < 2){
    			alert("A mensagem precisa ter no mÃ*nimo 2 caracteres.");
    			$("#messageContent").focus();
    			return false;
    		}else {
    			$("form[name=post]").submit();
    			return false;
    		}
    	});
    Thanks anyways
     
  2. The Doctor

    The Doctor Jr. VIP Jr. VIP

    Joined:
    Dec 18, 2010
    Messages:
    988
    Likes Received:
    304
    Occupation:
    Computer Scientist, Engineer, Programmer.
    Location:
    ☆☆☆☆☆☆
    Home Page:
    is there a form tag?
     
  3. Ceg3xow

    Ceg3xow Newbie

    Joined:
    Jul 6, 2011
    Messages:
    18
    Likes Received:
    1
    no, that's why I couldn't do it, I searched it the whole source code, I can send the page by PM if you want
     
  4. The Doctor

    The Doctor Jr. VIP Jr. VIP

    Joined:
    Dec 18, 2010
    Messages:
    988
    Likes Received:
    304
    Occupation:
    Computer Scientist, Engineer, Programmer.
    Location:
    ☆☆☆☆☆☆
    Home Page:
    go ahead
     
  5. Ceg3xow

    Ceg3xow Newbie

    Joined:
    Jul 6, 2011
    Messages:
    18
    Likes Received:
    1
    oops, I can't send PMs until I have 15 posts, lol
    anyways, is there anyway to simulate me clicking on that submit button ?
     
    Last edited: Jul 10, 2011
  6. Xooor

    Xooor Newbie

    Joined:
    Aug 14, 2011
    Messages:
    18
    Likes Received:
    17
    Could you not post the URL here so we can go check for ourselves. It seems unlikely that there is no form tag.

    Otherwise, no you can't simulate clicking the button with server-side PHP code, you could do so by simulating a browser, but that just get's messy. What I would do is get HTTP request logger (there are a lot of addons for firefox that do so) and then log all your HTTP requests.

    And from there you should be able to determine, which URL the data is sent to and how.
     
  7. xenon2010

    xenon2010 Regular Member

    Joined:
    Apr 27, 2010
    Messages:
    231
    Likes Received:
    48
    Occupation:
    web and desktop apps programmer
    Location:
    prison
    Home Page:
    get rid of the jquery codes. all you need basic javascript function which collects all the data from the text fields you will be able to select them using their ids. then post the collected data using "ajax" function. data will be posted to another page and then you just return the outputted data to the <div> element or whatever element you want.