Jump to content

How to run php script with post form tag in putty terminal?


sneaky

Recommended Posts

I am trying to create my own method of receiving texts which are alerts from a website. In this script I am using php, I get the html of a site on another domain, then paste its html into the current page, then use jquery to extract information from it, then use its click() button to submit a form with the data in a textarea tag, which then gets passed to a php code. There I send a text with the info to me. This works so far. But now I am trying to automate this in putty terminal using cron. But using the command "nohup php myscript.php", it seems to run the php file (contents of the php file gets outputted on the termainal), but I am not receiving any texts. I think it has something to do with the submit button.

 

Does anyone know a technique that I can use to solve this problem so that the putty code above will work?

 

Thanks.

 

<html>
    <head>
        <title>
            Test
        </title>

        <script type="text/javascript" src="Includes/jquery-1.8.1.min.js">
        </script>

    </head>

    <body>
        <?php

            $Fname = $_POST["new_movies"];
            if (isset($Fname)) {
                $formatted_number = "4163958750@msg.telus.com";
                $pieces = explode("\n", $Fname);

                $count = 0;
                $build = "";

                foreach ($pieces as &$value) {
                    $build = $build.$value."\n";

                    $count = $count + 1;
                    if ($count==2) {
                        $count = 0;
                        mail("$formatted_number", "", "$build");
                        $build = "";
                    }
                }
            }
            else {
                $contents = file_get_contents( "http://extratorrent.com/" );
                echo "$contents";
            }
        ?>

        <form method="post" action="<?php echo $PHP_SELF;?>" style="display:none">
            <textarea rows="5" cols="20" id="my_text_field" name="new_movies" wrap="physical"></textarea>
            <br />
            <input id="my_submit_button" type="submit" value="submit" name="submit"></input>
        </form>

        <script type="text/javascript">
                var build = "";

                var g = $('.tl').eq(0);
                g = $('.tlr, .tlz', $(g));

                for (var i=0; i<g.length; i+=1) {
                    val = $ ( 'a', $ ('td', g[i]) ).attr('title');
                    val = val.substr(9);
                    val = val.substring(0, val.length-;
                    build += val;

                    if (i < g.length-1) {
                        build += '\n';
                    }
                }
                $('#my_text_field').val(build);
                if ($('#my_text_field').val().trim() != "") { 
                    $('#my_submit_button').click();
                }
        </script>


    </body>
</html>

Link to comment
Share on other sites

You've massively overcomplicated this issue, and you really should start from scratch.

Use cURL to fetch the data, and then use DOMdocument to fetch the data you're looking from, and then send it via whatever method you want.

 

Ignore PuTTY as it doesn't have anything to do with the actual problem, no more than the editor you're using to write the code with. Simplify the problem to the bare essentials, and always ask yourself "is there a better/simpler way to do this"? You do not want to solve the entire problem at once, doing so will only overwhelm you and cause you to create a sub-optimal solution (like the one you have). That is, if you get a solution at all.

Divide it up into lots of smaller tasks instead, and solve them one by one while considering their impact on the whole.

 

You don't climb Mount Everest in one big leap, after all, but one step at a time.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.