user2740217
user2740217

Reputation: 175

simple HTML form not working?

I have really basic problem but cant seem to find problem. I have a simple HTML form which i cant get to work (cant even go to google.com), so i was wondering if you can see any obvious mistake i am missing here.

<form action="www.google.hr" id="questionForm" method="post">
                    <fieldset>
                        <legend>Naputci za studente:</legend>       
                        <textarea name="help" id="help"><?php print($result['Help']); ?></textarea><br><br>
                        <input type="submit" value="Update" id="create"/>
                    </fieldset>
                </form>

Thank you all for your help, unfortuneantly nothing helped resolve this issue so it must be something else thats bothering this part of code. Once again, I appriciate all your help.

Edit:

I was looking through google chrome developer tools and it seems that it doesnt "read" form line, anyway i have a screenshot so here it is?

No <form> line???

Upvotes: 0

Views: 112

Answers (2)

D&#233;j&#224; vu
D&#233;j&#224; vu

Reputation: 783

Try intead of action="www.google.hr" to do action="http://www.google.hr" so:

<form action="http://www.google.hr" id="questionForm" method="post">
    <fieldset>
        <legend>Naputci za studente:</legend>       
        <textarea name="help" id="help"><?php print($result['Help']); ?></textarea>
        <br><br>
        <input type="submit" value="Update" id="create"/>
    </fieldset>
</form>

As patrick stated in his answer, a GET can be applied too, instead of POST, this will take all the values and literally places them inside the URL.

If i changed this form to GET it will send this url:

https://www.google.hr/?help=%3Cbr+%2F%3E%0D%0A%3Cb%3ENotice%3C%2Fb%3E%3A++Undefined+variable%3A+result+in+%3Cb%3EC%3A%5Ccode%5COpdrachten+Bram%5CPHPStorm%5CKeyword+Density+Tool%5Cretrieve_url.php%3C%2Fb%3E+on+line+%3Cb%3E87%3C%2Fb%3E%3Cbr+%2F%3E%0D%0A

Anyway, if i change the action attribute to something.php for example. And hit the submit button it goes directly to something.php, wheter it's post or get. So your form is correctly made. I think you should look somewhere else in your code.

Upvotes: 3

Patrick Hofman
Patrick Hofman

Reputation: 156948

Two problems:

  • You should prefix your url with http://;
  • Google does not accept cross-domain posts. Try get:

    <form action="http://www.google.com/" id="questionForm" method="get">
        <fieldset>
            <legend>Naputci za studente:</legend>       
            <textarea name="q" id="q"></textarea><br><br>
            <input type="submit" value="Update" id="create"/>
        </fieldset>
    </form>
    

Test this on a local file, since jsfiddle will block this kind of requests.

Upvotes: 1

Related Questions