Data content not rendering on the webpage: Server not replying back - php

My page is made in php, I have qcodo which is layered on top of my database for the website.
Occasionally, the webpage does not render and instead of the content it should display it displays the website URL in the body. This problem started occurring after I added few fields in the database. At first I thought this might be a qcodo problem, so I tried qcube on a test page but the problem was not fixed.
Can anyone point me to right direction, I think it is the server that is not sending a sent content message to the client.

No errors? Try to turn on error and warnings.
If the error is not consistent then it could be your web/db server is busy.

Uhm, something very similar happened to me long time ago. It ended up it was due to an empty line that was somehow appended to one of my .php files.

Related

PHP Page does not load data till I refresh after form submit

I have a main php Admin page that allows me to edit information contained within my database. I have several forms on the page, and a tabbed setup that allows me to nest the edit forms within each tab. All the forms refer Action="" back to the same php page for process and the page naturally looks to see if a button isset after POSTing otherwise just loads the usual tables and does not UPDATE the database.
Prior to web deployment I utilise XAMPP to develop the pages, however, once contented with the pages I upload to HostPapa. Whilst in the XAMPP environment, when i submit my information to be processed the page loads fine, the database is UPDATEd and the Success Message displays fine. However, once I upload to HostPapa and attempt the same steps, once i click the submit button and the data is sent back to the same page for processing, only a blank screen appears. When i hit refresh though it completes the processing and displays the Success Message. Data is UPDATEd in the database and nothing else appears to be wrong.
My questions are:
Any idea why my localhost website would display fine but my live version kind of stutters through the processing
Is this a setting on HostPapa that may need changing
Have i fallen pray to a coding taboo that prompts this response in the live environment
Worth noting that I had another XAMPP/HostPapa issue where I had not utilised the correct file name with Capitals in a form and this caused a failure as the file name did not match the coded file name exactly. This was rectified by insuring that file names and coded file name were match and case sensitive. The local XAMPP server did not care about case sensitivity which makes be believe that the form submission issue noted above may be a PHP option on HostPapa that is currently turn one.
Any assistance in this matter would be appreciated.
Regards,
C
To anyone who reads this and had a similar issue when utilising multiple forms on the same page. My issue is I had breaks(empty rows) between my <?php ?> tags in the header of the document.
I used several <?php ?> tags to encompass the different $_POST functions for my own clarity. This caused the server to interpret these breaks(empty rows) as an intentional space and made it appear that the header had already been sent. So naturally as my page attempted to load, the server believed i was attempting modify the header that had already been sent.
I believe this coding faux pas was masked by XAMPP during my offline build. I did a bit more research and I believe this also has something to do with the UTC selection.
At any rate, thank you Dony for attempting to assist. It was a hard issue to articulate.
Regards,
Cheyne

403 Forbidden if input contains "script"

I am facing one kinda odd problem and I'd appreciate any help.
I am looking to have a page submit a Google Adsense code and then save it to the database (I have a input field to accept GA code and a submit button, very simple form)
The thing is, I always get 403 forbidden when submiting a form, if input field contain "<script>" as a value.
If I try to submit anything else it works fine, but I can't figure out why text must not contain "<script>".
Note: it's not a problem with mysql escape or something similar, it happens even if I comment out complete PHP code. It just seems like POST won't accept this.
Another thing to mention, this problem DOES NOT occurs in localhost (xampp), but only when uploaded to Namecheap hosting.
Any ideas why this happens and how to make a workaround?
Namecheap has probably configured mod_security rules on their servers so to block posts which contain tags as these tags being allowed to be posted back to a webpage opens the door to very serious client side scripting vulnerabilities if the web app doesn't handle this correctly. If the post can even make it to php (which in your case it can't) you should be able to call htmlspecialchars or htmlentities on it to filter these out. If Namecheap is doing this for you and this is a problem then there's not much you can do other than changing hosts as shared hosting doesn't allow you any say over server configuration.
I had this problem, I needed to use tags in the form I was submitting in the admin system (embedding a google adsense ad).
To fix I edited the .htaccess file and added the line
SecFilterEngine Off
I only needed to do this temporarily to get the job done & turn it back on when I'm done.

"The connection was reset" showing up on old code

I have a form with about 25 inputs and the code to process it. The last time the code was edited in any way was 3 weeks ago. I randomly started getting reset connection issues. To investigate, I began cutting out sections of the code to find the guilty sections (cut section, refresh, repeat). Once I narrowed it down to a particular section (one which when I cut it out, the error did not occur), I started to repeat the process with smaller sections of the culprit section. Finally, I had the entire section commented out. Still got the error. Then I deleted the commented out sections and no error!
This leads me to conclude that the error isn't in my code, but some recent change to the configuration of the server (I host with GoDaddy) or something like that. Any suggestions as to what could cause this error? I've never removed comments from code and fixed an error before.
Further information: The form loads correctly initially. Clicking any of the buttons gives me the error, however the code does completely precess before the error (I do some file in/output so I can see that it's working). This even happens with the "Clear All" button which skips the section I mentioned above, and simply reloads the form.
I am using no database interaction whatsoever. The script does utilize both Facebook and twitter APIs.
I really don't know how to proceed from this point. I'm willing to post the code from the entire file if necessary, but my investigation reveals that to be pointless. I can also provide a link to the offending page.
Update: I commented out all the code except the output of the HTML form itself. No processing code at all. Just one function to output the form. Clicking any button causes the connection reset. However if I delete this commented out code, I do NOT get the connection reset, the form just reloads.
Update #2. I uploaded the site to another host. The code runs fine with no issues.
Update #3. After an exhaustive examination, I've determined that the cause of the problem is the following function call:
preg_replace('/\b(\w)/e', 'strtoupper("$1")', $_POST['dessert_name'])
If I comment out this line, I get the connection reset error... If I delete it, the script runs perfectly.
You need to increase your php timeout limit in php.ini
This in my experience is almost always a timeout.
max_execution_time = 60
or at the top of your script add
set_time_limit(60);

Reasons why POST won't work when moving CodeIgniter site to another domain

I'm using CodeIgniter next to a Wordpress install.
So, I've got this site that I developed on one server. That works fine. I've moved it to another server and actually hacked it up to make another site which also works fine.
So now I've moved that site to a third server and my forms aren't posting right, or something.
They are submitting to the correct controller but when I var_dump $_POST or $this->input->post('anyvariable') Im getting empty arrays and falses.
I'm banging my head against the wall over this. I'm thinking maybe it's a .htaccess problem as nothing else has changed from the other sites.
Can anyone suggest a way to resolve this?
Ok so i turns out that I was getting a 301 redirect when I submitted the form because in my codeigniter config file i didn't put http://www.mysite.com but instead had http://mysite.com.
Thats why my post data was being cleared but I was still reaching the correct controller to do the var_dump.
I noticed this after checking the Net tab in firebug.
I should have realized this sooner but i was coding for 12 hours already when I got to this point because I needed to make a deadline.
In the config file check all settings and especially $config['base_url']. Maybe when you use form_open(method_name), form doesn't redirect correctly.
Sounds like you're not posting any data to the page. Are you sure the URL is correct, and you're working on the right file? Perhaps add a print at the top to make sure you're editing the right file, and posting to the right one as well. Also, consider using wireshark or something to see the raw POST request, to see if the data is in fact there. Not sure what else to tell you at this point.

Controller actions being called twice --- Php application

I'm new around so if I'm missing some info or something, please let me know and I'll provide it. I've already looked for informationg regarding this error, but I haven't found anything relevant yet.
So, here's the deal.. Some of my controllers actions are being called twice, and I've just noticed that when I was wondering why was I sending SOME mails twice (the application I've got has an email client incorporated).. and only then after logging what was I doing I noticed the controller gets called twice... By the way, this only happens when I called the action from a link outside the application or by typing the url.
If I'm not making myself clear or I'm missing something, please do post here anyway so I can add more info..
Thanks in advance!
Aggregating possible answers from other sources as per my comment:
<img src="" /> and relatives.
If you have places where you generate the src attribute of the img tag, make sure it isn't empty in any freak cases; a handful of browsers take the empty src as a prompt to load the page again. 1, 2, 3
The same is true for an empty favicon, javascript or css href - generally anything where you're asking the browser to fetch an external resource, but no url is supplied, even in css1.
The phenomenom is perhaps a more understandable if you consider, for example, where you're sending form data when you do <form action=""> (or even just <form>) - namely the same page.
.htaccess shenanigans.
Check your rewrite rule(s): Are you making the server take a roundtrip to your script for any static content (e.g. favicon1)? Do non-existent files trigger a call to your script, and is an external resource link pointing to one (e.g. an ancient css stylesheet that was finally deleted from the filesystem but someone forgot to remove it from the HTML source)?
Browser-based debuggers.
Some browser-based debuggers, e.g. firebug1, will send a second request to the page depending on circumstances, to gather data that wasn't natively supplied to them by the browser itself. Make sure you're not getting that.
See if any of those help you.
For me, having Firebug open was causing the page to be called twice.
Without seeing the actual application code, I'm left to simply guess - however, I know of at least one semi-famous bug in this arena, see http://blog.codekills.net/archives/27-Fun-with-Firefox-Jitters.html for the details - basically, it happens when a <tr> has an onclick handler and an <a> inside that goes to the same URL...and even if this isn't what your app does, perhaps you can gain some insight from seeing how they went about debugging the problem.
After hours of debugging, my issue was a dynamically set background-image css tag. If there was no image - background-image:url() - a second request would be made back to the controller once the page was loaded.
Just in-case anyone else is doing the same.
My particular version of the problem and fix
submitting this form worked on a production server, but not "localhost"
For Firefox: form worked in both places. For Chrome: only worked on production server
setting breakpoints in my problem controller confirmed it was getting called multiple times (duh) and CSRF protection on that form got gibbered up as a result.
Then I found this thread: http://ellislab.com/forums/viewthread/210318/
My solution involved the favicon. The src attribute wasn't quite right. I did have a favicon in the root directory and it loaded on the hompage but not others (didn't notice that for a while). Anyways, providing an absolute path to the favicon solved it
Don't really know if you MUST have a favicon, but like mentioned above, make sure any resources you pull in (img/js/css) are properly referenced so as to avoid a browser retrying to request a page
On my Code Igniter View, I have a Form. THe form has a Post method calling url of controllerA. On clicking Add button in the form, I was calling a Javascript function that validates email ID. After validating email in .js, I was posting some data using $.post(url...) to the controllerA for database insertion. The insert was happening twice.
It turned out that in the $.post(url) I was calling controllerA url.
When I commented that $.post, database insert worked fine.

Categories