I've a strange problem with PHP function header('location:anylink'); and is not a coding issue as the exact same script (is my script) works fine in other installations. Have checked it in at least 10 other websites from my clients, with different server configurations and works fine.
An example: I've in my code a check to see if the article id exists in database. If does not exists, it redirects to homepage. If exists, it shows the article page.
Some tests where the article id does not exists and (correctly) redirects to Blog homepage:
https://www.hostbignet.com/blog.php?do=article&id=400
https://oraclewebhost.org/blog.php?do=article&id=400
and here is the link in my site. As you can see it continue code execution and it shows the page, of course with empty data.
https://www.whmup.com/blog.php?do=article&id=400
Have tried at least a dozen of suggestions that I found here in similar issues but nothing changed. I used ob_start, I wrote Location instead location, I let space before URL, I added exit and exit() below redirection. Nothing solved the issue.
My code is (I tried even with adding the domain name before):
// Redirect Back
header('location:blog.php');
In addition. I even tried with window.location.href and window.location.replace Nothing again.
My server is CentOS 7 with CWP Pro.
Thank you
Chris
I was able to fix this issue by saving the file as ANSI. Whatever else encoding that I tried, does works.
Related
First off, I ran into this issue when transferring all of my files from my localhost (wamp server) to my web server via FileZilla. Everything works great on my test server but when looking at it on my domain it doesn't appear the same nor does it function the same.
I tried to research this issue before asking and closest thing I found was this question here which doesn't help me with my specific problem.
What my test servers looks like and how the website should function on the web-server:
Show the sign-up and sign-in buttons on the navigation bar.
Show the proper content accordingly from the action page.
What my website is doing when uploading it to the web-server:
Shows the sign-up & sign-in buttons when navigating to the website (www.heartfx.org/test)
Does not display proper content like my localhost server does with the action page.
So instead of a user being linked to an external page for each function like login.php, register.php, forgot_password.php etc... they are linked to a single page like http://www.heartfx.org/action.php?action=register_account where I then $_get['action'] and display each "page".
The code on my web-server for some reason doesn't display those "pages" but only the navigation bar on top of the page and nothing under it.
How /action.php?action=sign_in should look(as it does on local server):
How /action.php?action=sign_in looks on the web-server:
Another thing to mention: I also have this question being posted / answered on, on another community where someone had me run the following line down the code until I ran into a spot where the line number didn't echo;
echo '<br>Line: ' .__LINE__; die;
The line number echo'd completely fine until I placed the line of code underneath a showHeader(''); function in my action.php page. When placing the line of code underneath a showHeader(''); function it did not echo the line number as it should with that statement.
We figured it was due to something with the showHeader(''); function which is being included in common.inc.php but cannot figure out what is wrong with the function that is causing it to not display each "page". The code on the web-server is exactly the same it is on the localhost server other then database credentials.
UPDATE: So after sitting idle at an action page (specifically I was at /action.php?action=register_account) for about 10 minutes and refreshing the page the module appeared as it should've when first loading the page. When roaming around the page for a bit and refreshing a 2nd time it AGAIN goes blank and run into the same issue.
Finally tracked down what was causing this issue and how to fix it. Inside of the showHeader('') that I am calling is another checkLogin() function that includes a Teamspeak3 query that displays my teamspeak server. That query for some reason was messing up the rest of my code (including the action.php page where I am trying to display everything.
Also would explain why very rarely I seen the page actually work and refreshing it, again made the page blank (other then the navigation bar) because the teamspeak query was still loading - causing the rest of the page not to load.
To fix this I simply removed the query from common.inc.php as it is not a mandatory function to have on my site. Thanks to everyone that helped me track down the issue.
/*
// Don't report any php errors.
error_reporting(0);
// load framework files
require_once("includes/libraries/TeamSpeak3/TeamSpeak3.php");
// connect to server, authenticate and spawn an object for the virtual server on port xxxx
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://serverquerylogin:ATJ75oPF#63.251.20.99:14012/?server_port=14010&use_offline_as_virtual=1&no_query_clients=1");
// build and display HTML treeview using custom image paths (remote icons will be embedded using data URI sheme)
echo $ts3_VirtualServer->getViewer(new TeamSpeak3_Viewer_Html("includes/images/viewer/", "", "data:image"));
// Report all php errors again.
error_reporting(-1);
*/
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.
I have a pretty strage problem im dealing with.
Lost sessionvariables in firefox.
Im using wordpress and have a subpage that causes the loss.
More specific:
In wordpress there exists a page called My pages (Original page names are in swedish, translated for convinience)
Under this page i have a few subpages. Among these are a page called Create test. There is nothing special about this page, for now only contains the phrase "hello world". If I enter any page other that this, it works.
But this particular page just seems to clear my session variables (wich I use to store login info)
I tried deleting the page in question in the effort to remake it.
While it was deleted I tried navigating around on the page.
Create test was the last item in the subnavigation menu, and now when its gone, the same thing happens on the last menuitem (now Account settings). This leave me to believe its something with the menu.
Even more strange, after recreating Create test, so that this page is now the last item. Still it's Account settings that is the page with the resetting of sessionvars...
I have through echo determined that the session id stays the same, just the variables that get unset.
I have unset($_SESSION['id']); at only one place, and this code is NOT run.
The problem just baffles me and I have no idea why this particular pages does this.
It may be totally unrelated, but we had problem with Firefox and sessions on certain pages in the past. It happened most of the times while developing and therefore refreshing a particular page, have you tried clearing your browser cookies which is where session is stored?
As an addition:
Check that you assign sessions before you write anything to the response stream.
Also we had similar problems with sessions set in a pages that were doing a redirection (i.e. a login page that if successful would set the session and redirect to the another page.)
I'm not sure about PHP but in .NET that can be overcome by explicitly setting not to terminate the response so that all headers are written to the response stream.
Fixed now, actually have no idea what I did. but I've change some html but mostly CSS.
So there is a strong posibility it was CSS-related.
I have a problem.
I ma moving a system from one server to another and I came across a peculiar problem. There are some pages placed in a subfolder like these:
xttp://test.domain.com/admin/oders.php
xttp://test.domain.com/admin/users.php
xttp://test.domain.com/admin/whatever.php
Now, when I move around the pages, via some simple menu with links I get most of the times correct hits. But from time to time I end up on say:
xttp://test.domain.com/admin/admin/oders.php - which obviously causes 404
When I go back to previous page and press the link again it again works all right. Also when I hover over the links they always show proper paths regardless of whether I am going to get 404 or not. All links are dynamically generated by the scripts but they work perfectly on old server and as I say to a naked eye it all looks OK, right until I press the link.
Anyone has an idea where to look for a bug or which tool to use to see what is happening when I press the link? URL mod rewrite? Domain configuration? I am at a loss.
It sounds like the scripts are getting confused between
[xttp://test.domain.com]/admin/file.php
admin/file.php
file.php
Without seeing how the URLs are generated it's impossible to say how this is happening.
I'm trying to understand code that I bought so I can modify it.
In the index.php there are picture links:
<a href="test10,10"><img title="" border=1
src="makethumb.php?pic=product_images/test101.jpg&w=121&sq=N" / ></a>
I don't understand the href since it is not pointing to a page. test10 is an id of a picture. I assumed it was going back to the index.php and the code would extract the test10,10 from the url, but it's not. I know that because I put in trace code as the first line.
The question is, where is the link going to?
I know it that it somewhere in the process it executes a page called profile.php, but nowhere in the source code (doing a global search) is there an explicit call to profile.php.
As a related question, is there a way to profile the code to see what pages it's calling without using xdebug, which for the life of me I can't get working after many hours of trying every suggestion I found here and else where. (I'm using xampp)
The flow is: you enter the site www.site.com/final/index.php. which displays pictures with the link as above. When you click on the picture with an id of test10 it takes you to www.site.com/final/test10,1
thanks
The question is, where is the link going to?
Under normal circumstances, a request to
www.yourdomain.com/current_directory/test10,10
is made.
Usually, Apache will try to find a file of that name, and fail.
If the behaviour you get is different, then there is probably a mod_rewrite rule set up somewhere. Look for .htaccess files (note, files in parent directories affect all children) and check the httpd.conf, httpd-vhosts.conf and other log files for any RewriteRule settings.