Realbasic How to submit an HTML form in code

917 views Asked by At

I'm struggling with how to click the 'Submit' button on an HTML form using code. I seem to be able to set the variables - Name, Email etc - using the HTTPSocket but when the socket 'Posts' it doesn't trigger the submit.

Any help will be gratefully received

Cheers,

Alan McTavish ...

RB 2008 r1 ... no plugins please.

Hi again,

The code I am using is the example given with the software - HTTP Example.rbp. It reads the website code and asks me to give the values for the input fields in the HTML. However, the form doesn't seem to be submitted.

The HTML on the server is as follows:

<!DOCTYPE html><!-- HTML5 -->
<html lang="en" dir="ltr">
    <head>
        <title>ActivationNoted - Infosoft</title>
        <meta charset="utf-8" />
        <!--[if IE]><meta http-equiv="ImageToolbar" content="False" /><![endif]-->
        <meta name="author" content="Ian Shere" />
        <meta name="generator" content="Incomedia WebSite X5 Professional 10.1.0.39 - www.websitex5.com" />
        <meta name="viewport" content="width=774" />
        <link rel="icon" href="favicon.png" type="image/png" />
        <link rel="stylesheet" type="text/css" href="style/reset.css" media="screen,print" />
        <link rel="stylesheet" type="text/css" href="style/print.css" media="print" />
        <link rel="stylesheet" type="text/css" href="style/style.css" media="screen,print" />
        <link rel="stylesheet" type="text/css" href="style/template.css" media="screen" />
        <link rel="stylesheet" type="text/css" href="style/menu.css" media="screen" />
        <!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="style/ie.css" media="screen" /><![endif]-->
        <link rel="stylesheet" type="text/css" href="pcss/activationnoted.css" media="screen" />
        <script type="text/javascript" src="res/jquery.js?39"></script>
        <script type="text/javascript" src="res/x5engine.js?39"></script>

    </head>
    <body>
        <div id="imHeaderBg"></div>
        <div id="imFooterBg"></div>
        <div id="imPage">
            <div id="imHeader">
                <h1 class="imHidden">ActivationNoted - Infosoft</h1>

            </div>
            <a class="imHidden" href="#imGoToCont" title="Skip the main menu">Go to content</a>
            <a id="imGoToMenu"></a><p class="imHidden">Main menu:</p>
            <div id="imMnMn" class="auto">
                <ul class="auto">
                    <li id="imMnMnNode0">
                        <a href="index.html">
                            <span class="imMnMnFirstBg">
                                <span class="imMnMnTxt"><span class="imMnMnImg"></span>Home Page</span>
                            </span>
                        </a>
                    </li><li id="imMnMnNode11">
                        <a href="features-of-footware.html">
                            <span class="imMnMnFirstBg">
                                <span class="imMnMnTxt"><span class="imMnMnImg"></span>Features of footware</span>
                            </span>
                        </a>
                    </li><li id="imMnMnNode12">
                        <a href="download.html">
                            <span class="imMnMnFirstBg">
                                <span class="imMnMnTxt"><span class="imMnMnImg"></span>Download</span>
                            </span>
                        </a>
                    </li><li id="imMnMnNode14">
                        <a href="support.html">
                            <span class="imMnMnFirstBg">
                                <span class="imMnMnTxt"><span class="imMnMnImg"></span>Support</span>
                            </span>
                        </a>
                    </li><li id="imMnMnNode3">
                        <a href="contact-us.html">
                            <span class="imMnMnFirstBg">
                                <span class="imMnMnTxt"><span class="imMnMnImg"></span>Contact Us</span>
                            </span>
                        </a>
                    </li>
                </ul>
            </div>
            <div id="imContentGraphics"></div>
            <div id="imContent">
                <a id="imGoToCont"></a>
                <h2 id="imPgTitle">ActivationNoted</h2>
                <div style="width: 754px; float: left;">
                    <div style="float: left; width: 377px;">
                        <div id="imCell_1" class="imGrid[0, 0]"><div id="imCellStyleGraphics_1"></div><div id="imCellStyle_1"><form id="imObjectForm_1" action="imemail/imEmailForm_160xo79k.php" method="post" enctype="multipart/form-data" style="width: 365px; margin: 0; padding: 0; text-align: left;">
                            <fieldset class="first">
                                <div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_1" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">Name</label><br /><input type="text" class="" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_1" name="imObjectForm_1_1" /></div>
                        <div class="imClear" style="height: 1px; line-height: 1px; width: 365px;"></div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_2" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">E-mail</label><br /><input type="text" class="valEmail" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_2" name="imObjectForm_1_2" /></div>
                        <div class="imClear" style="height: 1px; line-height: 1px; width: 365px;"></div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_3" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">Address</label><br /><input type="text" class="" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_3" name="imObjectForm_1_3" /></div>
                        <div class="imClear" style="height: 1px; line-height: 1px; width: 365px;"></div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_4" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">Address2</label><br /><input type="text" class="" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_4" name="imObjectForm_1_4" /></div>
                        <div class="imClear" style="height: 1px; line-height: 1px; width: 365px;"></div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_5" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">Address3</label><br /><input type="text" class="" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_5" name="imObjectForm_1_5" /></div>
                        <div class="imClear" style="height: 1px; line-height: 1px; width: 365px;"></div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_6" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">Address4</label><br /><input type="text" class="" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_6" name="imObjectForm_1_6" /></div>
                        <div class="imClear" style="height: 1px; line-height: 1px; width: 365px;"></div>
                                    <div style="float: left; margin: 0; padding: 0 0 2px;"><label for="imObjectForm_1_7" style="vertical-align: top; display: inline-block; margin: 3px 0 2px 0; width: 351px;">Activation Key issued</label><br /><input type="text" class="" style="float: left; width: 347px; margin-right: 10px; vertical-align: top; padding-top: 2px; padding-bottom: 2px;" id="imObjectForm_1_7" name="imObjectForm_1_7" /></div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <input type="text" id="imObjectForm_1_prot" name="imSpProt" />
                            </fieldset>
                            <div style="width: 365px; text-align: center;">
                                <input type="submit" value="Send" />
                                <input type="reset" value="Reset" />
                            </div>
                        </form>
                        <script>x5engine.boot.push('x5engine.imForm.initForm(\'#imObjectForm_1\', false, {type: \'tip\', showAll: true, classes: \'validator\', landingPage: \'index.html\', labelColor: \'#000000\', fieldColor: \'#000000\', selectedFieldColor: \'#000000\'})');</script>
                        </div></div>
                    </div>
                    <div style="float: left; width: 377px;">
                        <div style="height: 435px;">&nbsp;</div>
                    </div>

                </div>
                <div style="width: 754px; float: left;">
                    <div style="height: 15px;">&nbsp;</div>
                </div>

                <div id="imFooPad" style="height: 0px; float: left;">&nbsp;</div><div id="imBtMn"><a href="index.html">Home Page</a> | <a href="features-of-footware.html">Features of footware</a> | <a href="download.html">Download</a> | <a href="support.html">Support</a> | <a href="contact-us.html">Contact Us</a> | <a href="imsitemap.html">General Site Map</a></div>                  
                <div class="imClear"></div>
            </div>
            <div id="imFooter">

                <div onclick="x5engine.utils.location('copyright-notice.html'); return false;" style="position: absolute; top: 22px; left: 393px; width: 54px; height: 16px; cursor: pointer;"></div>
                <div onclick="x5engine.utils.location('terms-and-conditions-of-use.html'); return false;" style="position: absolute; top: 22px; left: 468px; width: 113px; height: 16px; cursor: pointer;"></div>
                <div onclick="x5engine.utils.location('privacy-policy.html'); return false;" style="position: absolute; top: 22px; left: 597px; width: 76px; height: 16px; cursor: pointer;"></div>
                <div onclick="x5engine.utils.location('disclaimer.html'); return false;" style="position: absolute; top: 22px; left: 688px; width: 59px; height: 16px; cursor: pointer;"></div>
            </div>
        </div>
        <span class="imHidden"><a href="#imGoToCont" title="Read this page again">Back to content</a> | <a href="#imGoToMenu" title="Read this site again">Back to main menu</a></span>

    </body>
</html>

I emphasise that this is not my code.

I wonder if I need to get my friend to use a different setup on the website. Perhaps some PHP or whatever.

As always, any help gratefully received.

Alan ...

1

There are 1 answers

0
AleMac On

Sometimes the site you are sending post, do not accept "robots" doing this, like Facebook, for example.

Did you tried to send the post like this:

Dim sock As New HTTPSocket Dim d As New Dictionary dim r as string

d.Value("idA") = "xpto"

d.Value("idB") = "xzy"

d.Value("idC") = "abc"

sock.SetFormData(d)

r = sock.Post("imemail/imEmailForm_160xo79k.php", 30)