473,545 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code problem: Form will only work under GET method

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 "<form name=\"postcomm ent\" action=\"".HTTP _ROOT."/pages/
comment.php\" method=\"POST\" >\n";
print "Nome:<br/><input type=\"text\" name=\"nome\" size=\"64\" /><br /
>";
print "Email(obrigató rio; não será publicado):<br/><input type=\"text
\" name=\"email\" size=\"64\" /><br />";
print "Site:<br/><input type=\"text\" name=\"url\" size=\"64\" /><br /
>";
(...)
print "</form>\n";

This is the code that creates the form. The target page has this code
in it:

//print_pre is a function that prints "<pre>".print_r (var,true)."</
pre>", for debugging
print_pre($_POS T);
print_pre($_GET );
print_pre($_REQ UEST);

When method is POST, here's what I get:

Array
(
)
Array
(
)
Array
(
)

But when method is GET, this comes instead:

Array
(
)
Array
(
[nome] =Bruno Guedes
[email] =bruno_guedesav %40yahoo.com.br
[url] =about%3Ablank
(...) //There are more fields, but they aren't important
)
Array
(
[nome] =Bruno Guedes
[email] =bruno_guedesav %40yahoo.com.br
[url] =about%3Ablank
(...) //Again, there *are* mroe fields, but they don't matter
[PHPSESSID] =09772a2105568a 91612fdd33d49d8 212
)

So, sorry for the long post, but what's the big deal, anybody knows?
Nov 19 '07 #1
8 2562
On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav
<br************ @yahoo.com.brwr ote:
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 "<form name=\"postcomm ent\" action=\"".HTTP _ROOT."/pages/
comment.php\" method=\"POST\" >\n";
print "Nome:<br/><input type=\"text\" name=\"nome\" size=\"64\" /><br /
>";
print "Email(obrigató rio; não será publicado):<br/><input type=\"text
\" name=\"email\" size=\"64\" /><br />";
print "Site:<br/><input type=\"text\" name=\"url\" size=\"64\" /><br /
>";
(...)
print "</form>\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?
--
Rik Wasmus
Nov 19 '07 #2
bruno_guedesav wrote:
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.
Has your server been able to accept other POST forms OK -- is it just
this one that's causing problems?

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 13 days, 16:40.]

USD/EUR Exchange Rate Graph
http://tobyinkster.co.uk/blog/2007/11/18/usd-eur/
Nov 20 '07 #3
On 20 nov, 07:44, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
bruno_guedesav wrote:
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.

Has your server been able to accept other POST forms OK -- is it just
this one that's causing problems?
There's another form that goes fine on POST, and it has the same
inputs: text, checkbox, and textarea.
Nov 20 '07 #4
On 19 nov, 16:38, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav

<bruno_guede... @yahoo.com.brwr ote:
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 "<form name=\"postcomm ent\" action=\"".HTTP _ROOT."/pages/
comment.php\" method=\"POST\" >\n";
print "Nome:<br/><input type=\"text\" name=\"nome\" size=\"64\" /><br /
";
print "Email(obrigató rio; não será publicado):<br/><input type=\"text
\" name=\"email\" size=\"64\" /><br />";
print "Site:<br/><input type=\"text\" name=\"url\" size=\"64\" /><br /
";
(...)
print "</form>\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:

<form name="postcomme nt" action="http://www.dcc.ufmg.br/~guedesav/
PbBlog/pages/comment.php" method="POST">
<p class="disclaim er">AVISO: seu comentário pode ser enviado para
moderação caso:<br/>
a) não contenha um nome de autor;<br/>
b) contenha material impróprio;<br/>
c) seja, possivelmente, spam;<br/>
Caso seu comentário não seja spam, mas sim um comentário legítimo,
aguarde algumas horas e a justiça será feita. Obrigado pela
paciência.</p>Nome:<br/><input type="text" name="nome" size="64" /
><br />Email(obrigató rio; não será publicado):<br/><input type="text"
name="email" size="64" /><br />Site:<br/><input type="text" name="url"
size="64" /><br /><p>Comentário: <br /><textarea cols="56" rows="8"
name="content"> </textarea></p><input type="checkbox"
name="notify">N otificar respostas a comentário</input><br/>
<p class="captcha" >Responda a esta simples pergunta:
<img style="display: block; text-align: center" src="http://
www.dcc.ufmg.br/~guedesav/PbBlog/img/captcha22589648 5.png" />

<input type="text" name="captcha-answer" size="16" />
<input type="hidden" name="captcha-key"
value="*908BE2B 7EB7D7567F7FF98 716850F59BA69AA 9DB" />
</p>
<br /><input type="submit" value="Enviar Comentário" />
</form>

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?
Nov 20 '07 #5
On Tue, 20 Nov 2007 12:04:17 +0100, bruno_guedesav
<br************ @yahoo.com.brwr ote:
On 19 nov, 16:38, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
>On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav
<bruno_guede.. .@yahoo.com.brw rote:
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:

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:
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/~guedes...me=etc.etc.etc.
Content-Length: 561
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

Your site is not at <http://www.dcc.ufmg.br/~guedesav/PbBlog/>, it's at
<http://homepages.dcc.u fmg.br/~guedesav/PbBlog/>, and as the server is set
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="./pages/comment.php" or
action="/~guedesav/PbBlog/pages/comment.php"),
- or configure the server to do this kind of redirects internally instead
of external.

While the (X)HTML was not the problem it is really in need of cleaning up.
Not a PHP issue though. (</inputcan never, ever exist in current (X)HTML
for instance).
--
Rik Wasmus
Nov 20 '07 #6
On 20 nov, 16:04, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Tue, 20 Nov 2007 12:04:17 +0100, bruno_guedesav

<bruno_guede... @yahoo.com.brwr ote:
On 19 nov, 16:38, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav
<bruno_guede... @yahoo.com.brwr ote:
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 willonlypass
it's fields forward under methodGET, 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'twork/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:

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/~guedes...ment.php?nome=....
Content-Length: 561
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

Your site is not at <http://www.dcc.ufmg.br/~guedesav/PbBlog/>, it's at
<http://homepages.dcc.u fmg.br/~guedesav/PbBlog/>, and as the server is set
up to do an external redirect, and browsers will NOT post to the 'new'
page they're redirected to, they'll perform aGET, and POST values will be
lost.

Either:
- use the proper host in the url in your form (http://homepages...),
- use a relative url (action="./pages/comment.php" or
action="/~guedesav/PbBlog/pages/comment.php"),
- or configure the server to do this kind of redirects internally instead
of external.

While the (X)HTML was not the problem it is really in need of cleaning up.
Not a PHP issue though. (</inputcan never, ever exist in current (X)HTML
for instance).
--
Rik Wasmus
Oh, right, this makes sense, now. Thank you very much for the help,
I'll redefine the address constant, then. Thanks again!
Nov 20 '07 #7
Rik Wasmus:
(</inputcan never, ever exist in current (X)HTML for instance).
Never say never. </inputcan occur as an end-tag in XHTML, but for
compatibility there is an RFC "should" in its way.

--
Jock
Nov 20 '07 #8
On Nov 20, 9:04 pm, bruno_guedesav <bruno_guede... @yahoo.com.br>
wrote:
On 19 nov, 16:38, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
On Mon, 19 Nov 2007 19:29:38 +0100, bruno_guedesav
<bruno_guede... @yahoo.com.brwr ote:
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 "<form name=\"postcomm ent\" action=\"".HTTP _ROOT."/pages/
comment.php\" method=\"POST\" >\n";
print "Nome:<br/><input type=\"text\" name=\"nome\" size=\"64\" /><br /
>";
print "Email(obrigató rio; não será publicado):<br/><input type=\"text
\" name=\"email\" size=\"64\" /><br />";
print "Site:<br/><input type=\"text\" name=\"url\" size=\"64\" /><br /
>";
(...)
print "</form>\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:

<form name="postcomme nt" action="http://www.dcc.ufmg.br/~guedesav/
PbBlog/pages/comment.php" method="POST">
<p class="disclaim er">AVISO: seu comentário pode ser enviado para
moderação caso:<br/>
a) não contenha um nome de autor;<br/>
b) contenha material impróprio;<br/>
c) seja, possivelmente, spam;<br/>
Caso seu comentário não seja spam, massim um comentário legítimo,
aguarde algumas horas e a justiça será feita. Obrigado pela
paciência.</p>Nome:<br/><input type="text" name="nome" size="64" /><br />Email(obrigató rio; não será publicado):<br/><input type="text"

name="email" size="64" /><br />Site:<br/><input type="text" name="url"
size="64" /><br /><p>Comentário: <br /><textarea cols="56" rows="8"
name="content"> </textarea></p><input type="checkbox"
name="notify">N otificar respostas a comentário</input><br/>
<p class="captcha" >Responda a esta simples pergunta:
<img style="display: block; text-align: center" src="http://www.dcc.ufmg.br/~guedesav/PbBlog/img/captcha22589648 5.png" />

<input type="text" name="captcha-answer" size="16" />
<input type="hidden" name="captcha-key"
value="*908BE2B 7EB7D7567F7FF98 716850F59BA69AA 9DB" />
</p>
<br /><input type="submit" value="Enviar Comentário" />
</form>

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?
Maybe I'm missing something here but where does this:

<p class="captcha" >Responda a esta simples pergunta:

get closed? As far as I can see all your input fields are inside this
tag (in the code you posted.)

HINT: With the online validator you often need to read back a few
lines to find the real bug)
Nov 22 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
5660
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
25
2311
by: Delta | last post by:
Drop Down Menu Mozilla : work well widowed elements such as drop downs, except for flash movies IE : work well so far http://pwp.netcabo.pt/falmartins/index.htm
18
18326
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
11
4520
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing opinion of how I want to handle the 'user experience' in the application I'm creating. While I know I could allow the user to enter in number and alpha...
4
4385
by: Dennis Sjogren | last post by:
Greetings! First, I'm not 100% sure where to post this question. I use VB.NET for this project, but it's really a design question (a question on which method to use when solving this problem). In this medium sized (30 or so forms) application, our users have requested a more visual notification of when the client (this app) is...
7
1602
by: Mike Rand | last post by:
I am having a really hard time trying to get some client side code hooked up in VS2005, ASP 2.0. The code is in an .inc file (vbscript). The first problem I am encountering is the ASP.NET page doesn't like vbscript and throws fits about the syntax. Second, the page throws fits about the server side code tags (<% ... %>),...are these...
6
2332
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system...
20
14279
by: Frank Rizzo | last post by:
I have a class that handles events from another class. Unfortunately these events arrive on a different thread. How can I marshal the code execution to the thread on which the caller class was created. 'example public class MyClass { private ClassWithEvents cls = new ClassWithEvents(); public MyClass()
11
2763
by: Nathan Sokalski | last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls using the Add method of the Attributes collection. However, if the JavaScript code contains certain characters, such as & or < or several others, it converts them to html, such as &amp; or &lt; which can sometimes cause my scripts not to work. How can I prevent ASP.NET from...
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.