badboibillie
asked on
Super weird form post problem...happened when I switch servers
I just recently switched servers and it's been giving me problems. I checked the config files and didn't notice anything drastically different.
Here's the situation. Let's say I have an email newsletter signup form on the first page called "home.php." The field name is called "email". When I submit, it goes to "newsletter.php," where there is are other "profile" fields, along with an "email" field that has been prefilled based on what you entered on the previous ("home.php") page. Simple enough right?
Now on that second page, for the value of "email", I set it to <?=$HTTP_POST_VARS["email" ]?> so it could pull the variable from the previous page. THAT'S ALL.
Now since I switched servers, I've been getting very weird results. Let's say I enter "me@me.com", on the next page it would spit out "me@me.comemail=me@me.com. " This is basically the "valuename=value." It's really screwing things up, esp. since I've never had this problem before.
Any suggestions?
Here's the situation. Let's say I have an email newsletter signup form on the first page called "home.php." The field name is called "email". When I submit, it goes to "newsletter.php," where there is are other "profile" fields, along with an "email" field that has been prefilled based on what you entered on the previous ("home.php") page. Simple enough right?
Now on that second page, for the value of "email", I set it to <?=$HTTP_POST_VARS["email"
Now since I switched servers, I've been getting very weird results. Let's say I enter "me@me.com", on the next page it would spit out "me@me.comemail=me@me.com.
Any suggestions?
Try $_POST['email'] instead. You may be on a server with a newer PHP and something is broken with the old way.
ASKER
It is a newer version but it's PHP Version 4.2.2. But still, no luck...doesn't work.
If you pass it directly through the url, i.e. newsletter.php?email=me@me .com, that works fine.
So it has to do with the posting...
If you pass it directly through the url, i.e. newsletter.php?email=me@me
So it has to do with the posting...
ASKER
allow_call_time_pass_refer ence
On On
allow_url_fopen
1 1
always_populate_raw_post_d ata
0 0
arg_separator.input
& &
arg_separator.output
& &
asp_tags
Off Off
auto_append_file
no value no value
auto_prepend_file
no value no value
browscap
no value no value
default_charset
no value no value
default_mimetype
text/html text/html
define_syslog_variables
Off Off
disable_functions
no value no value
display_errors
On On
display_startup_errors
Off Off
doc_root
no value no value
enable_dl
On On
error_append_string
no value no value
error_log
no value no value
error_prepend_string
no value no value
error_reporting
2039 2039
expose_php
On On
extension_dir
/usr/lib/php4 /usr/lib/php4
file_uploads
1 1
gpc_order
GPC GPC
highlight.bg
#FFFFFF #FFFFFF
highlight.comment
#FF9900 #FF9900
highlight.default
#0000CC #0000CC
highlight.html
#000000 #000000
highlight.keyword
#006600 #006600
highlight.string
#CC0000 #CC0000
html_errors
On On
ignore_user_abort
Off Off
implicit_flush
Off Off
include_path
.:/usr/share/pear .:/usr/share/pear
log_errors
Off Off
magic_quotes_gpc
On On
magic_quotes_runtime
Off Off
magic_quotes_sybase
Off Off
max_execution_time
30 30
memory_limit
8M 8M
open_basedir
no value no value
output_buffering
no value no value
output_handler
no value no value
post_max_size
8M 8M
precision
14 14
register_argc_argv
On On
register_globals
On On
safe_mode
Off Off
safe_mode_exec_dir
no value no value
safe_mode_gid
Off Off
safe_mode_include_dir
no value no value
sendmail_from
me@localhost.com me@localhost.com
sendmail_path
/usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
short_open_tag
On On
SMTP
localhost localhost
sql.safe_mode
Off Off
track_errors
Off Off
unserialize_callback_func
no value no value
upload_max_filesize
2M 2M
upload_tmp_dir
no value no value
user_dir
no value no value
variables_order
EGPCS EGPCS
xmlrpc_error_number
0 0
xmlrpc_errors
Off Off
y2k_compliance
Off Off
here are the basic configurations for my config file...sorry for the bad formatting
On On
allow_url_fopen
1 1
always_populate_raw_post_d
0 0
arg_separator.input
& &
arg_separator.output
& &
asp_tags
Off Off
auto_append_file
no value no value
auto_prepend_file
no value no value
browscap
no value no value
default_charset
no value no value
default_mimetype
text/html text/html
define_syslog_variables
Off Off
disable_functions
no value no value
display_errors
On On
display_startup_errors
Off Off
doc_root
no value no value
enable_dl
On On
error_append_string
no value no value
error_log
no value no value
error_prepend_string
no value no value
error_reporting
2039 2039
expose_php
On On
extension_dir
/usr/lib/php4 /usr/lib/php4
file_uploads
1 1
gpc_order
GPC GPC
highlight.bg
#FFFFFF #FFFFFF
highlight.comment
#FF9900 #FF9900
highlight.default
#0000CC #0000CC
highlight.html
#000000 #000000
highlight.keyword
#006600 #006600
highlight.string
#CC0000 #CC0000
html_errors
On On
ignore_user_abort
Off Off
implicit_flush
Off Off
include_path
.:/usr/share/pear .:/usr/share/pear
log_errors
Off Off
magic_quotes_gpc
On On
magic_quotes_runtime
Off Off
magic_quotes_sybase
Off Off
max_execution_time
30 30
memory_limit
8M 8M
open_basedir
no value no value
output_buffering
no value no value
output_handler
no value no value
post_max_size
8M 8M
precision
14 14
register_argc_argv
On On
register_globals
On On
safe_mode
Off Off
safe_mode_exec_dir
no value no value
safe_mode_gid
Off Off
safe_mode_include_dir
no value no value
sendmail_from
me@localhost.com me@localhost.com
sendmail_path
/usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
short_open_tag
On On
SMTP
localhost localhost
sql.safe_mode
Off Off
track_errors
Off Off
unserialize_callback_func
no value no value
upload_max_filesize
2M 2M
upload_tmp_dir
no value no value
user_dir
no value no value
variables_order
EGPCS EGPCS
xmlrpc_error_number
0 0
xmlrpc_errors
Off Off
y2k_compliance
Off Off
here are the basic configurations for my config file...sorry for the bad formatting
and try <?php instead of <?
ASKER
okay, just to let you know. it worked perfectly fine on the old server. I've pretty much tried everything. I also showed it to the engineers at my company and they have no clue....so I think it has to do with configurations on the server.
I've tried every variation of <?php echo or whatever, so no hope.
It's gotten to the point where I will pay $50 to whoever solves this problem of mine =)
I've tried every variation of <?php echo or whatever, so no hope.
It's gotten to the point where I will pay $50 to whoever solves this problem of mine =)
if you just want to parse string
me@memail.comemail=me@mema il.com for example to
me@memail.com use some script for it.
$mail = "me@mail.comemail=me@mail. com";
$mail = substr($mail, (strrpos($mail, "=")+1));
if you really cant figure out what else to do, i mean.
me@memail.comemail=me@mema
me@memail.com use some script for it.
$mail = "me@mail.comemail=me@mail.
$mail = substr($mail, (strrpos($mail, "=")+1));
if you really cant figure out what else to do, i mean.
ASKER
What's even weirder is sometimes it doesn't add that extra key=value pair...usually when the input is short.
I had already come up with a parse:
#************************* ********
#** Weird parsing of all variables in header
if (isset($HTTP_POST_VARS)) {
while(list($key, $value) = each($HTTP_POST_VARS)) {
$thevalue = $key."=";
if($position = strpos($value,$thevalue)) $value = substr($value,0,$position) ;
eval ("$\$key = \"$value\";");
}
}
#************************* ********
But still doesn't explain the problem...
I had already come up with a parse:
#*************************
#** Weird parsing of all variables in header
if (isset($HTTP_POST_VARS)) {
while(list($key, $value) = each($HTTP_POST_VARS)) {
$thevalue = $key."=";
if($position = strpos($value,$thevalue)) $value = substr($value,0,$position)
eval ("$\$key = \"$value\";");
}
}
#*************************
But still doesn't explain the problem...
dont use http_post_vars
check what is inside $_POST
<?php
print("<pre>");
print_r($_POST);
print("</pre>");
?>
write the output here
check what is inside $_POST
<?php
print("<pre>");
print_r($_POST);
print("</pre>");
?>
write the output here
ASKER
Array
(
[email] => me@me.comemail=me@me.com
)
(
[email] => me@me.comemail=me@me.com
)
hmm...
what about the submit form..
what is the code for <input name='email'>
what about the submit form..
what is the code for <input name='email'>
ASKER
it's a basic HTML type form,
<form name="whatever" action="newsletter.php" method="post">
<input type="text" name="email" value="Input text" />
<input type="submit" name="submit" />
</form>
<form name="whatever" action="newsletter.php" method="post">
<input type="text" name="email" value="Input text" />
<input type="submit" name="submit" />
</form>
and you say that this form gives you me@me.comemail=me@me.com without any parsing?? can't understand!!
must be configuration mistake..
must be configuration mistake..
do a phpinfo() on BOTH servers and post results here.
Have you tried the old fashioned tag (No />)
<form name="whatever" action="newsletter.php" method="post">
<input type="text" name="email" value="Input text">
<input type="submit" name="submit">
</form>
<form name="whatever" action="newsletter.php" method="post">
<input type="text" name="email" value="Input text">
<input type="submit" name="submit">
</form>
absolutely, missed this :D
ASKER
llow_call_time_pass_refere nce On On
allow_url_fopen 1 1
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_functions no value no value
display_errors On On
display_startup_errors Off Off
doc_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 2039 2039
expose_php On On
extension_dir ./ ./
file_uploads 1 1
gpc_order GPC GPC
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF9900 #FF9900
highlight.default #0000CC #0000CC
highlight.html #000000 #000000
highlight.keyword #006600 #006600
highlight.string #CC0000 #CC0000
html_errors On On
ignore_user_abort Off Off
implicit_flush Off Off
include_path .: .:
log_errors Off Off
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
max_execution_time 30 30
open_basedir /usr/local/plesk/apache/vh osts/vietd ao.com/htt pdocs no value
output_buffering Off Off
output_handler no value no value
post_max_size 8M 8M
precision 14 14
register_argc_argv On On
register_globals On On
safe_mode On On
safe_mode_exec_dir /nonexec /nonexec
sendmail_from me@localhost.com me@localhost.com
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
short_open_tag On On
SMTP localhost localhost
sql.safe_mode Off Off
track_errors Off Off
upload_max_filesize 2M 2M
upload_tmp_dir /tmp /tmp
user_dir no value no value
variables_order EGPCS EGPCS
y2k_compliance Off Off
----------------
sorry, if this looks really ugly, i'll try to post an easier-to-read one, but AAAAAAAAAAH this is getting on my nerves..
allow_url_fopen 1 1
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_functions no value no value
display_errors On On
display_startup_errors Off Off
doc_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 2039 2039
expose_php On On
extension_dir ./ ./
file_uploads 1 1
gpc_order GPC GPC
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF9900 #FF9900
highlight.default #0000CC #0000CC
highlight.html #000000 #000000
highlight.keyword #006600 #006600
highlight.string #CC0000 #CC0000
html_errors On On
ignore_user_abort Off Off
implicit_flush Off Off
include_path .: .:
log_errors Off Off
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
max_execution_time 30 30
open_basedir /usr/local/plesk/apache/vh
output_buffering Off Off
output_handler no value no value
post_max_size 8M 8M
precision 14 14
register_argc_argv On On
register_globals On On
safe_mode On On
safe_mode_exec_dir /nonexec /nonexec
sendmail_from me@localhost.com me@localhost.com
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
short_open_tag On On
SMTP localhost localhost
sql.safe_mode Off Off
track_errors Off Off
upload_max_filesize 2M 2M
upload_tmp_dir /tmp /tmp
user_dir no value no value
variables_order EGPCS EGPCS
y2k_compliance Off Off
----------------
sorry, if this looks really ugly, i'll try to post an easier-to-read one, but AAAAAAAAAAH this is getting on my nerves..
is this the old server's ?
and above the new one's ?
and above the new one's ?
BTW, I would also see the "Apache environment" section and the "additional modules" one
the best is to run the phpinfo function on both servers, to dump (save as... complete HTML page) the two pages somewhere I can look at them via a browser.
May-be I'll find something :D
May-be I'll find something :D
Temporarily, try using method="GET" and $_GET is the browser sending the wrong info?
Richard.
Richard.
ASKER
as a matter of fact...it is!
when i do post, everything is right....it sends the right variables with key/values, and it is evident in the URL.
The problem is with my POST in the form...so any ideas?
when i do post, everything is right....it sends the right variables with key/values, and it is evident in the URL.
The problem is with my POST in the form...so any ideas?
Can we see the form live? With a print_r($_POST) / print_r($_GET) in it too?
Are you POSTing or GETing the data?
Try the other method. Any change?
Are you POSTing or GETing the data?
Try the other method. Any change?
ASKER
okay like the post before this, I said that I just found out the problem lies in the POST (i.e. $_POST/$HTTP_POST_VARS).
Here's what happens with both:
1) $_POST:
when I submit from a field "email" the value "me@me.com" in a post, i get this on the receiving page -
it spits out "me@me.comemail=me@me.com"
2) $_GET
on the other hand, get spits out everything correctly -
me@me.com
----------------------
You'r saying just change everything to "_GET", but that doesn't solve my problems. I have about 30 pages of admin that use the "_POST" so I need to get this solved. Any suggestions?
Here's what happens with both:
1) $_POST:
when I submit from a field "email" the value "me@me.com" in a post, i get this on the receiving page -
it spits out "me@me.comemail=me@me.com"
2) $_GET
on the other hand, get spits out everything correctly -
me@me.com
----------------------
You'r saying just change everything to "_GET", but that doesn't solve my problems. I have about 30 pages of admin that use the "_POST" so I need to get this solved. Any suggestions?
How are you printing this out? Also, what is the exact HTML for this field in the form?
ASKER
see above...its a normal mehtod for printing it out <?=$email?>
I've also tried every variation of that also.
And the form is a normal HTML form.
I've also tried every variation of that also.
And the form is a normal HTML form.
Did you try the old tags yet?
(i.e. get rid of the \> and make them > )
(i.e. get rid of the \> and make them > )
ASKER
i've tried that. but it doesn't matter. It's XHTML standard syntax. It has nothing to do with the PHP.
like i said earlier, it's a server configuration problem.
like i said earlier, it's a server configuration problem.
I am sorry to keep asking, but I need to see a snippet of you code, your exact code, and not a "representation" of what your code is. I want to see both your "exact" HTML and your "exact" PHP code surrounding this problem.
Depending on your exact code in both of these cases, I actually may know exactly what your problem is, but without seeing your code, I will not make the claim because it depends on a few things around what you are doing.
When I see code fragments that have "whatever" in them, then I am quite sure I am not looking at the exact code as it is in your source.
I am *not* asking you to divulge any proprietary code or anything that is going to compromise your code, just any loops in the PHP code and the <input tag "as it is" in yout page.
If you can not provide this, then I am backing away from this one and leaving it to the rest of you!
Depending on your exact code in both of these cases, I actually may know exactly what your problem is, but without seeing your code, I will not make the claim because it depends on a few things around what you are doing.
When I see code fragments that have "whatever" in them, then I am quite sure I am not looking at the exact code as it is in your source.
I am *not* asking you to divulge any proprietary code or anything that is going to compromise your code, just any loops in the PHP code and the <input tag "as it is" in yout page.
If you can not provide this, then I am backing away from this one and leaving it to the rest of you!
Also would like to see ...
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>
This will show EXACTLY what is being received in your script for the $_POST array.
It should show ...
Array
(
"email" => "me@me.com"
)
(Or similar, I typed this, so layout, etc may vary).
Richard.
<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>
This will show EXACTLY what is being received in your script for the $_POST array.
It should show ...
Array
(
"email" => "me@me.com"
)
(Or similar, I typed this, so layout, etc may vary).
Richard.
ASKER
Hello fellow experts,
I know that you guys are trying to help me out and I do appreciate it. It's not that I don't wanna divlue any info...but the truth to the matter is that THAT IS MY CODE!!!!
I dummied it down to the very least of html form requirements and the problem still exists.
As for the person who asked for the _POST print out, yes, it still prints out me@me.comemailme@me.com
I know that you guys are trying to help me out and I do appreciate it. It's not that I don't wanna divlue any info...but the truth to the matter is that THAT IS MY CODE!!!!
I dummied it down to the very least of html form requirements and the problem still exists.
As for the person who asked for the _POST print out, yes, it still prints out me@me.comemailme@me.com
Can we see EXACTLY what print_r($_POST); shows.
I want to see the names and how they are formatted.
Peer review of code is a good thing. Obviously, you need to edit out passwords or sitenames, etc. but the actual code will be what is causing the problem. If we see it we can fix it.
Imagine going to the garage and saying my car don't work. I think it is the wheels, but I'm not sure!
He will ask to see the car!
Same here.
We are all really good car mechanics, but we are not telepathic (well, some of us aren't).
So. Show the code. Let us all have a good laugh and you can move on to more important things like beer and sex.
Richard.
P.S. No offense intended.
I want to see the names and how they are formatted.
Peer review of code is a good thing. Obviously, you need to edit out passwords or sitenames, etc. but the actual code will be what is causing the problem. If we see it we can fix it.
Imagine going to the garage and saying my car don't work. I think it is the wheels, but I'm not sure!
He will ask to see the car!
Same here.
We are all really good car mechanics, but we are not telepathic (well, some of us aren't).
So. Show the code. Let us all have a good laugh and you can move on to more important things like beer and sex.
Richard.
P.S. No offense intended.
i agree
Like I said before, I actually think I know what it is, but unless I see the exact HTML and exact context around the PHP, I don't know for sure.
We want to help!
We want to help!
ASKER
Okay i give in! You guys will see what I mean...I mean honestly, I'm not trying to waste your time. Here is a test page that duplicates the live version:
1) Live Version (bug fixed ghetto way):
http://engrwp.usc.edu/illumin/index.php
(Mailing list at the bottom)
Sends to http://engrwp.usc.edu/illumin/mailinglist.php
------------------------
2) Bugged Version (_POST echoed on posted page)
http://engrwp.usc.edu/illumin/index2.php
Sends to http://engrwp.usc.edu/illumin/mailinglist2.php
3) Code Version:
http://engrwp.usc.edu/illumin/index2.txt
http://engrwp.usc.edu/illumin/mailinglist2.txt
1) Live Version (bug fixed ghetto way):
http://engrwp.usc.edu/illumin/index.php
(Mailing list at the bottom)
Sends to http://engrwp.usc.edu/illumin/mailinglist.php
------------------------
2) Bugged Version (_POST echoed on posted page)
http://engrwp.usc.edu/illumin/index2.php
Sends to http://engrwp.usc.edu/illumin/mailinglist2.php
3) Code Version:
http://engrwp.usc.edu/illumin/index2.txt
http://engrwp.usc.edu/illumin/mailinglist2.txt
ASKER
p.s. you might ask why I'm still persisting if I had already found a fix-around. The problem is that 1) that doesn't solve the problem and 2) this site is run off about 50 pages of backend administrative tools that I created for content management. they all require form submission and converting every form into GET is not feasible, and not possible given the size of certain posts that this site requires.
Ok, I trued the bugged version, and it gave me my email address exactly as I entered it everywhere, including the print_r
ASKER
what was your email? like in one of the posts i said before, the results are spontaneous...try me@me.com
No problems here.
With me@me.com
Can you try ...
<?=$_POST['email']?>
instead of
<?=$email?>
Does that make a difference.
With me@me.com
Can you try ...
<?=$_POST['email']?>
instead of
<?=$email?>
Does that make a difference.
ASKER
Okay I think I know why I'm getting different answers:
Instead of hitting submit, just press "return/enter" key after you enter your email.
Instead of hitting submit, just press "return/enter" key after you enter your email.
Aha! Tried it the second time and got the error.
Array
(
[email] => god@heaven.comemail=god@he aven.com
)
Are you using a cookie to hold information in a field called $email?
It looks like you have added the value to an existing field called $email somehow.
Use the $_POST['email'].
Array
(
[email] => god@heaven.comemail=god@he
)
Are you using a cookie to hold information in a field called $email?
It looks like you have added the value to an existing field called $email somehow.
Use the $_POST['email'].
I think it is the MM validator.
If you click the submit button, no problems on repeat submissions.
If you press enter whilst still editing, then the info is not sent correctly.
If you click the submit button, no problems on repeat submissions.
If you press enter whilst still editing, then the info is not sent correctly.
But the validator on the onClick event of submit button, not on the onBlur event of the input field.
That is Put, not But.
ASKER
okay took out all the javascript checking functions. it still messes up for me.
ASKER
honestly this is really the least of my worries. I'm having a much worst problem with POSTs in my management pages. the main reason I posted this first because I think they both share similar problems (check out http://engrwp.usc.edu/illumin/article.php?articleID=3 and how it duplicates the text).
So hopefully solving this error will fix that other one.
So hopefully solving this error will fix that other one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did any of this help you? If so, please award a grade to close this question.
ASKER
I actually forgot about this one. No one really provided any useful information and no one gave me any informatin I didn't already know. I found the answer to my problems in the PHP bug tracker, which - to my own guess - said that it was a problem in the PHP 4.2.2 version I was using. The link is here: http://bugs.php.net/bug.php?id=18648, and the problem was solved by upgrading the server and php version. So just to give some points out, I'll give it to the person with the closest answer.
LOL - And the most succinct answer too boot! :-)
LOL - And the most succinct answer to boot! :-)