?
Solved

Super weird form post problem...happened when I switch servers

Posted on 2003-03-04
50
Medium Priority
?
233 Views
Last Modified: 2006-11-17
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?
0
Comment
Question by:badboibillie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 19
  • 10
  • 10
  • +2
50 Comments
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8068508
Try $_POST['email'] instead.  You may be on a server with a newer PHP and something is broken with the old way.
0
 

Author Comment

by:badboibillie
ID: 8068554
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...
0
 

Author Comment

by:badboibillie
ID: 8068558
allow_call_time_pass_reference
 On On
allow_url_fopen
 1 1
always_populate_raw_post_data
 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
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 1

Expert Comment

by:Jonza
ID: 8069793
and try <?php instead of <?
0
 

Author Comment

by:badboibillie
ID: 8069867
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 =)
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8069888
if you just want to parse string
me@memail.comemail=me@memail.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.
0
 

Author Comment

by:badboibillie
ID: 8070037
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...
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8070058
dont use http_post_vars
check what is inside $_POST

<?php
 print("<pre>");
 print_r($_POST);
 print("</pre>");
?>

write the output here
0
 

Author Comment

by:badboibillie
ID: 8070101
Array
(
    [email] => me@me.comemail=me@me.com
)
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8070112
hmm...
what about the submit form..
what is the code for <input name='email'>
0
 

Author Comment

by:badboibillie
ID: 8070168
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>
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8070188
and you say that this form gives you me@me.comemail=me@me.com without any parsing?? can't understand!!

must be configuration mistake..

0
 
LVL 15

Expert Comment

by:VGR
ID: 8070500
do a phpinfo() on BOTH servers and post results here.
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8070510
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>
0
 
LVL 15

Expert Comment

by:VGR
ID: 8070529
absolutely, missed this :D
0
 

Author Comment

by:badboibillie
ID: 8070710
llow_call_time_pass_reference     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/vhosts/vietdao.com/httpdocs     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..
0
 
LVL 15

Expert Comment

by:VGR
ID: 8070865
is this the old server's ?
and above the new one's ?
0
 
LVL 15

Expert Comment

by:VGR
ID: 8070904
BTW, I would also see the "Apache environment" section and the "additional modules" one
0
 
LVL 15

Expert Comment

by:VGR
ID: 8070909
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
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8079867
Temporarily, try using method="GET" and $_GET is the browser sending the wrong info?

Richard.
0
 

Author Comment

by:badboibillie
ID: 8085566
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?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8087353
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?
0
 

Author Comment

by:badboibillie
ID: 8089680
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?

0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8089793
How are you printing this out?  Also, what is the exact HTML for this field in the form?
0
 

Author Comment

by:badboibillie
ID: 8090192
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.

0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8090271
Did you try the old tags yet?
(i.e. get rid of the \> and make them > )
0
 

Author Comment

by:badboibillie
ID: 8090353
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.
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8090421
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!
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8109850
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.
0
 

Author Comment

by:badboibillie
ID: 8114164
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

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8118517
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.
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8118536
i agree
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8118643
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!
0
 

Author Comment

by:badboibillie
ID: 8119272
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

0
 

Author Comment

by:badboibillie
ID: 8119307
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.

0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8119390
Ok, I trued the bugged version, and it gave me my email address exactly as I entered it everywhere, including the print_r
0
 

Author Comment

by:badboibillie
ID: 8119466
what was your email? like in one of the posts i said before, the results are spontaneous...try me@me.com
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8119521
No problems here.

With me@me.com

Can you try ...

<?=$_POST['email']?>

instead of

<?=$email?>

Does that make a difference.
0
 

Author Comment

by:badboibillie
ID: 8119563
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.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8119592
Aha! Tried it the second time and got the error.

Array
(
    [email] => god@heaven.comemail=god@heaven.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'].

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8119616
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.

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8119624
But the validator on the onClick event of submit button, not on the onBlur event of the input field.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8119627
That is Put, not But.
0
 

Author Comment

by:badboibillie
ID: 8119641
okay took out all the javascript checking functions. it still messes up for me.
0
 

Author Comment

by:badboibillie
ID: 8119675
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.
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 150 total points
ID: 8119795
Screwed server.

0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8547306
Did any of this help you?  If so, please award a grade to close this question.
0
 

Author Comment

by:badboibillie
ID: 8557882
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.
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8557947
LOL - And the most succinct answer too boot!  :-)
0
 
LVL 7

Expert Comment

by:Big_Red_Dog
ID: 8557953
LOL - And the most succinct answer to boot!  :-)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question