PHP runs only partially in MAMP - php

I recently setup a MAMP environment (v3.5)` to test my website locally rather than having to upload to the host.
The PHP works fine on the remote host, in this case the form will submit.
Here's a link: PHP Form
When I run the site locally only html and css work but the PHP pages show the first few lines of the POST sequence.
Partial run
This is the content shown in the viewport
Content-Type: application/x-www-form-urlencoded Content-Length: 59 sendername=&senderemail=&contactno=&user_message=&send=Send
As you can probably guess, this is not the result I am expecting. In the normal scenario, the acknowledgment.php page will load with a 'thank you' message.
Can anyone tell me what is wrong with the MAMP installation that would cause this?
Thank you very much indeed.

check if you put the method="post" attribute in your form
check if you close each tag
Check the version of php on your mamp: preferences -> php
Reeinstall your mamp
in any case if it does not work, you can try manually install php
other think will be that you post your code of file acknowledge.php to check for possible errors
I hope it helps you...

Thank you guys so much for your insight. I am so humbled by the help provided here!
I opened the acknowledgement.php file only to discover that somehow the content had been erased leaving only a few lines.
I corrected it, using the file from the remote host and it is working now!

Related

Entire PHP script being echo'd out instead of specific line

MCVE:
<?php
echo "testing!";
?>
Screenshot from accessing this script in Chrome:
Screenshot from running this script via the PHP command-line:
What's weird is that it hasn't always been this way. Everything was working perfectly yesterday, but ever since today, it's been doing this for whatever reason. Did I screw something up within the config of my Apache accidentally or something? Using XAMPP with PHP v7.3.8.
Wow, good catch KIKO Software! After checking the encoding of the file in Notepad++... I realized that it, for some reason, was set to "UCS-2 LE BOM". I changed it to "UTF-8" and now everything is working properly. Thank you!

Firefox: connection determined in PHP script

I've set up an Apache Server as localhost in a openSUSE 13.1 64 bit system and I'm currently testing my PHP scripts.
In Konquerer 4.11.5 everything seems fine, but with Firefox 29.0.1 there is a strange phenomenon:
Every 10th time or so the connection fails. Firefox reports: "Connection determined".
The failed connection is listed neither in error_log nor in access_log.
The error must be quite "early". Because my PHP script output.php calls "itself" via
header("Location: output.php?changed_url");
almost immediately, but the Firefox error is BEFORE output.php is opened for the second time.
I have no idea what to do about this. It's a quite annoying issue.
All answers will be appreciated! Thanks in advance!
I guess you are missing
exit;
after the header() location change.
So you have an open script, firefox redirecting to the next (itself) and still having one open, ... I think firefox doesn't like this kind of loop ;)
Do you have any .htaccess file there? Have you tried using firefox from different OS or computer? I bet it's related to your installation of firefox :) (i ain't pro take it as guess)

Cannot send a string of more than 1333 characters

I have a strange problem. I cannot send a form if one the fields has a string of more than 1333 characters.
Here's my simple html page:
<form method="POST">
<input type="hidden" name="a" value="WffapzB...truncated" />
<input type="submit" value="OK" />
</form>
The problem comes from Apache or my Computer since when I load the html file in the browser (file://localhost/Users/etienne/Developpement/htdocs/test/SendForm/index.html), without passing through the server, the form gets sent.
If I access it via the server (http://tests.localhost/SendForm/), the page times out.
Here's what I have tried:
Also, all the php and apache logs do not show anything...
I've set post_max_size = 500M
I've set LimitBodyRequest 0
You can see my phpinfo page here: http://jsfiddle.net/etiennenoel/VZfeQ/
What can cause a page not to accept strings longer than 1333 characters on server side ? Clearly, it is not a browser problem since it doesn't work on other browsers and it works using the html file. Therefore, the problem comes when the server is in the process.
Update 2
I completely removed MAMP Server and reinstalled the Mac OS X native server without success. Therefore, it is not linked with MAMP PRO but with other things that I have not clue about...
Update 3
I also found out that the same problem occurs sending the data via GET.
Update 4
Using wireshark on my local adapter, I see no POST data being sent. I see the http requests for that page but it doesn't show any POST requests. If I launch another site, then I will see the POST requests for that site. : https://docs.google.com/file/d/0B2quoUxT9OnJdmN3ajJVR2dPbUk/edit?usp=sharing
I finally found it ! After hours and days of searching, I decided to reactivate the firewall. Then, I got a request from a program called HideMyIp (that I completely forgot that I had installed). I deleted that program, restarted my computer, and everything was then working fine ! Thanks to everyone that have tried to help me !

Load php in local html

I have a problem with a local file, I don't know if it's possible but I like to know if its...
My code in my local HTML is:
$(document).ready(function(){
$("#load").load("http://localhost/prueba.php",{estado:"ok"});});
And the php online is:
<?php
echo '<script>alert("' . $_POST["estado"] . '");</script>';?>
If I run my local HTML like "http:// localhost /prueba.htm" runs fine!
But if I try to run my local file like "C:\documents\prueba.htm" not run the php code and that is what I need.
This is only an example, really I want to run a query in php and get me back my info to my HTML file.
Can anyone help me?
Sorry by my english its bad but I've no more options... any idea how to do it?
The main problem is that your request will not be allowed because of the browser's Same Origin Policy. Please have a look at jQuery Ajax request from local filesystem (Windows file:///)
Where did you place php code?
Make sure you put it in same folder.

Why is _POST sometimes empty when a textarea is posted in PHP

PHP 4.4 and PHP 5.2.3 under Apache 2.2.4 on ubuntu.
I am running Moodle 1.5.3 and have recently had a problem when updating a course. The $_POST variable is empty but only if a lot of text was entered into the textarea on the form. If only a short text is entered it works fine.
I have increased the post_max_size from 8M to 200M and increased the memory_limit to 256M but this has not helped.
I have doubled the LimitRequestFieldSize and LimitRequestLine to 16380 and set LimitRequestBody to 0 with no improvement.
I have googled for an answer but have been unable to find one.
HTTP Headers on firefox shows the content size of 3816 with the correct data, so its just not getting to $_POST.
The system was running fine until a few weeks ago. The only change was to /etc/hosts to correct a HELO issue with the exim4 email server.
I can replicate the issue on a development machine that has exim4 not running so I think it is just coincidence.
Thanks for your assistance.
I don't know enough to really provide a useful answer so the following is more a well-educated guess (at least I hope so).
First, you should debug the entire request, either by access_log or for example through firebug. (Good to have Firebug anyway.) To me your problem sounds like a redirect happens in between. I give you an example:
Assume this is your structure:
/form.php
/directory/index.php
This is your form:
<form action="/directory" method="post">
...
</form>
Problem in this case is, that even though /directory is a valid url, Apache will redirect you one more time to /directory/, thus you are loosing your payload (what is supposed to be in $_POST).
Could it be not the size related of the post, but how long the line is before a new line. If they use the Moodle WYSIWYG view the html would just get put into one line with no breaks. If you go into html and hit return around every 1000 characters does it work?
What is the enctype of the form? Could be that it limits the ammount of data send through the form.
You might also want to check the incoming raw $_POST data with:
file_get_contents('php://input');
To make sure their is actually data send.
Got these suggestions here.
It sounds like an Apache or Apache/PHP integration problem. If $_POST is empty it would hint that the http server is not giving the POST information to PHP. If I were you I'd investigate the Apache configuration.
This is obvious, but did you /etc/init.d/apache2 restart ?
Also, the error_log file should show some information about whether the post size exceeded the set limit. Consider increasing your verbosity for troubleshooting the issue

Categories