Example: pow server variables: GET overwrites POST

From PlainOldWebserver

Jump to: navigation, search

If your HTML form has a query string in it's action attribute and that query string contains a variable also contained in the form then the query string (GET variable) will overwrite the form input (POST variable) of the same name.

test.sjs

<html>
<head>
    <title>GET overwrites POST</title>
</head>
<body>
<form action="test.sjs?foo=foo-from-GET" method="POST">
    Foo: <input name="foo" value="foo-from-POST" /><br />
    Baa: <input name="baa" value="baa-from-POST" /><br />
    <input type="submit" />
</form>

<?sjs
    pow_info();
?>
</body>
</html>

returns

pow_server.REQUEST foo: foo-from-GET, baa: baa-from-POST
pow_server.POST    foo: foo-from-GET, baa: baa-from-POST 
pow_server.GET     foo: foo-from-GET

NOTE: the pow_server.POST contains GET variables. This is incorrect (POW server 0.1.7) as it should only contain the POST variables.

Personal tools
Navigation