Hi, This problem has me stumped. I have a local host setup on my home desktop and I put a copy on my notebook to occasionally do offsite work. Everything was fine on both machines but now when I go to the index.php on the notebook then click the login button it inserts this URL in the web browser
http://localhost/MJN/index.php/login.php
(and it essentially calls the index page again) when it should be inserting this
http://localhost/MJN/login.php
to go to the login page.
The desktop does not do this. The buttons are defined exactly the same on the desktop and the notebook. The only thing that might have changed the behavior on the notebook that I can figure is I used phpMyAdmin to first drop the database on the notebook then I created the blank database on the notebook again and used phpMyAdmin to download the MySql database from the VPS site and I imported that database in to the notebook database. I have done this at least 100 times from the desktop machine to the notebook without problem and this is the only time I have brought it in from the VPS service database. That VPS service database was an upload from the desktop in the first place and the structure has not changed. The problem is I have not gone in to the notebook local host database in probably a week so I can't for sure say when this problem was triggered. I am concerned about returning this VPS site database into the desktop machine now but it would be useful for debugging to do this. I can override the URL it creates and force it to go to http://localhost/MJN/login.php and get in to see the data base.
Thanks for any suggestions to figure this out (Apache config has not changed - no config files have changed).
John
Strange button click problem.
Moderator: General Moderators
Strange button click problem.
Last edited by bowlesj on Mon Mar 02, 2015 9:07 am, edited 3 times in total.
Re: Strange button click problem.
Directory structure the same on both machines? Sounds like maybe a relative link problem. Might be helpful if you posted some relevant code.
Re: Strange button click problem.
Thanks for responding Celauran. Yes the directory structures are the same on both machines and both the index.php page and login.php are the same (I copied them over from the desktop just now to double check).
I had no idea what to google so after your response I goggled this "browser relative link problem" and found a link which I am reading now.
https://yoast.com/relative-urls-issues/
The button code is the only code I know to provide.Sounds like maybe a relative link problem. Might be helpful if you posted some relevant code.
Code: Select all
<button id="Button_Login" type="button" onclick="window.location='Login.php'" name="Login" value="Login" style="position:absolute;left:813px;top:187px;width:168px;height:26px;z-index:1;" tabindex="1">
<div style="text-align:center"><span style="color:#000000;font-family:Arial;font-size:13px">Login</span></div>
</button>https://yoast.com/relative-urls-issues/
Re: Strange button click problem.
Yeah, definitely looks like a relative link issue. I tend to make all my links absolute specifically to avoid scenarios like this.
Re: Strange button click problem.
I have read about 50% of the page I mentioned that I was reading so now I kind of get it (helps to understand the unix and windows commands . and ..). The thing is all my web pages are in the same directory. So on the localhost they are in localhost/MJN/(then all my pages are here with no subdirectories). On the VPS machine they are all under the standard /var/www/html/(all my pages are here). This is much simpler than what he is describing. He also mentions this command <base href="http://www.example.com/subdirectory/"> which I had not heard of and I do not have this type of command. I could try importing the VPS database into my desktop and see if it creates the same problem again (but if it does I have a big headache - LOL - but I could do a disk image of the whole machine to recover from I guess). I will keep reading his article for now.
Re: Strange button click problem.
I figured it out (believe it or not!!!). Here is what is happening and it may be a win xp thing or maybe the xampp is not the same when installed on XP. I have created a $_GET parameter in the index.php page to allow me to get in to do testing while people who may have stumbled on my website will instead get a message saying the web site is not available until a certain date. So without giving away the parameter it looks like this
this is what I want to put in.
localhost/mjn/index.php?Parameter=Y
This is what it forces in the browser location bar (notice the extra forward slash before the question mark)
localhost/mjn/index.php/?Parameter=Y
Actually I am not sure where it inserted the slash. It might have been on the unix machine and I just assumed I needed it. Anyway, no matter.
Now the extra forward slash works fine on the desktop (under xampp with win 7) and I can click the login button and it works. However on the notebook (xampp under xp) it creates the problem. So I have to remove the forward slash and it fixes the problem. It is interesting that if I go into the hosts VPS under the notebook xp machine the forward slash before the ? does not create a problem. So again it relates back to xampp running under win XP.
So I guess I learned about absolute and relative URLs from this (actually from your comment Celauran). I guess on the unix VPS I am using absolute and on the local host I am using relative because of the insertion of the MJN directory down one level. I did that because I was doing some learning tests from a book and I had all the chapter examples in a different directory under the LocalHost. So it seems the initial call to the localhost/mjn/index.php sets the relative URL location up front and because I never play games with it after that point I am safe. I understand why not to use this in production now.
Thanks again, it helped me understand something I didn't understand before.
John
this is what I want to put in.
localhost/mjn/index.php?Parameter=Y
This is what it forces in the browser location bar (notice the extra forward slash before the question mark)
localhost/mjn/index.php/?Parameter=Y
Actually I am not sure where it inserted the slash. It might have been on the unix machine and I just assumed I needed it. Anyway, no matter.
Now the extra forward slash works fine on the desktop (under xampp with win 7) and I can click the login button and it works. However on the notebook (xampp under xp) it creates the problem. So I have to remove the forward slash and it fixes the problem. It is interesting that if I go into the hosts VPS under the notebook xp machine the forward slash before the ? does not create a problem. So again it relates back to xampp running under win XP.
So I guess I learned about absolute and relative URLs from this (actually from your comment Celauran). I guess on the unix VPS I am using absolute and on the local host I am using relative because of the insertion of the MJN directory down one level. I did that because I was doing some learning tests from a book and I had all the chapter examples in a different directory under the LocalHost. So it seems the initial call to the localhost/mjn/index.php sets the relative URL location up front and because I never play games with it after that point I am safe. I understand why not to use this in production now.
Thanks again, it helped me understand something I didn't understand before.
John