Re: Code problem: Form will only work under GET method

Re: Code problem: Form will only work under GET method

am 20.11.2007 12:04:17 von bruno_guedesav

On 19 nov, 16:38, "Rik Wasmus" wrote:
> On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav
>
>
>
> wrote:
> > This has ocurred before, but if the person had find a way to solve it
> > or not, I've got no clue. So, here I am to ask for help.
>
> > I've created a form via pure PHP, basically a bunch of prints together
> > making a form. But somthing strange goes on: the form will only pass
> > it's fields forward under method GET, but not on POST.
>
> > Here's a snippet of code, just the basics:
>
> > print "

> > comment.php\" method=3D\"POST\">\n";
> > print "Nome:
=

> >> ";
> > print "Email(obrigat=F3rio; n=E3o ser=E1 publicado):
"text
> > \" name=3D\"email\" size=3D\"64\" />
";
> > print "Site:
<=
br /
> >> ";
> > (...)
> > print "
\n";
>
> I'm not going to check that quote-escape festival just yet. Try to
> validate the page it creates with the w3c HTML validator, most likely you =

> error will show up there.
>
> If after that it still doesn't work/there are no errors, what form does
> your code actually output, and how does your webserver log the request?

The HTML validator goes fussy on some input tag it claims it's closed
but not opened, when it clearily is. Here's the HTML output of the
form:

PbBlog/pages/comment.php" method=3D"POST">

AVISO: seu coment=E1rio pode ser enviado para
moderação caso:

a) n=E3o contenha um nome de autor;

b) contenha material impr=F3prio;

c) seja, possivelmente, spam;

Caso seu coment=E1rio n=E3o seja spam, mas sim um coment=E1rio leg=EDtim=
o,
aguarde algumas horas e a justi=E7a ser=E1 feita. Obrigado pela
paci=EAncia.

Nome:
>
Email(obrigat=F3rio; n=E3o ser=E1 publicado):
"
name=3D"email" size=3D"64" />
Site:
l"
size=3D"64" />

Coment=E1rio:

name=3D"notify">Notificar respostas a coment=E1rio

Responda a esta simples pergunta:
www.dcc.ufmg.br/~guedesav/PbBlog/img/captcha225896485.png" />


value=3D"*908BE2B7EB7D7567F7FF98716850F59BA69AA9DB" />






Besides, as I said, the form works finely in GET method, but not in
POST. If it goes fine with GET, how come the problem is with the
syntax?

Re: Code problem: Form will only work under GET method

am 20.11.2007 19:04:59 von luiheidsgoeroe

On Tue, 20 Nov 2007 12:04:17 +0100, bruno_guedesav =

wrote:
> On 19 nov, 16:38, "Rik Wasmus" wrote:
>> On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav
>> wrote:
>> > This has ocurred before, but if the person had find a way to solve =
it
>> > or not, I've got no clue. So, here I am to ask for help.
>>
>> > I've created a form via pure PHP, basically a bunch of prints toget=
her
>> > making a form. But somthing strange goes on: the form will only pas=
s
>> > it's fields forward under method GET, but not on POST.
>>
>> > Here's a snippet of code, just the basics:
>>
>> I'm not going to check that quote-escape festival just yet. Try to
>> validate the page it creates with the w3c HTML validator, most likely=
=

>> you
>> error will show up there.
>>
>> If after that it still doesn't work/there are no errors, what form do=
es
>> your code actually output, and how does your webserver log the reques=
t?
>
> The HTML validator goes fussy on some input tag it claims it's closed
> but not opened, when it clearily is. Here's the HTML output of the
> form:

I hate to play validator, I distilled the location of the online form =

though, so let's have a go at submitting the form:

HTTP/1.x 302 Found
Date: Tue, 20 Nov 2007 17:55:05 GMT
Server: Apache/2.0.59 (FreeBSD) mod_ssl/2.0.59 OpenSSL/0.9.7e PHP/5.1.4
Location: =

http://homepages.dcc.ufmg.br/~guedesav/PbBlog/pages/comment. php?nome=3De=
tc.etc.etc.
Content-Length: 561
Keep-Alive: timeout=3D15, max=3D100
Connection: Keep-Alive
Content-Type: text/html; charset=3Diso-8859-1

Your site is not at , it's at =
=

, and as the server is s=
et =

up to do an external redirect, and browsers will NOT post to the 'new' =

page they're redirected to, they'll perform a GET, and POST values will =
be =

lost.

Either:
- use the proper host in the url in your form (http://homepages...),
- use a relative url (action=3D"./pages/comment.php" or =

action=3D"/~guedesav/PbBlog/pages/comment.php"),
- or configure the server to do this kind of redirects internally instea=
d =

of external.

While the (X)HTML was not the problem it is really in need of cleaning u=
p. =

Not a PHP issue though. ( can never, ever exist in current (X)HT=
ML =

for instance).
-- =

Rik Wasmus