2018-08-10 02:58
浏览 71


I'm fairly new to php/html so bear with me.

So in the home page of my website, the login link takes the user to either

  1. The login page
  2. The user page if they had already logged in

Before implementing this fully, I decided to check whether or not I could get a simple php link to work and im glad i did because it does not work.

I have currently:

<a href="<?php echo 'login.html';?>">Login</a>

This is supposed to go to login.html when clicked on but when you click on the link you get this Corresponding error log from XAMPP's appache error.log:

[Thu Aug 09 21:51:30.257273 2018] [core:error] [pid 37376:tid 1948] (20024)The given path is misformatted or contained invalid characters: [client ::1:49721] AH00127: Cannot map GET /poll/%3C?php%20echo%20%27login.html%27;?%3E HTTP/1.1 to file, referer: http://localhost/poll/Poll_home.html

If instead of the above code I put

<a href="login.html">Login</a>

then it works fine and links me to the login page. Any help would be great!


Problem is fixed by creating a new php file (test.php).

<a href="test.php">Login</a>

But when I try to make the link dynamic by changing the test.php to this:

if(session_status() == PHP_SESSION_NONE){ //if already logged on
    header("Location: login.html");
else{ //If not
    header("Location: sign-up.html");

It always goes to login.html even when I am not logged on.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqmhgz5848 2018-08-10 03:21

    As per error message

    Cannot map GET /poll/%3C?php%20echo%20%27login.html%27;?%3E HTTP/1.1 to file, referer: http://localhost/poll/Poll_home.html

    It says that you are writting PHP code in Poll_home.html file, which is the problem, you should write PHP code in php file (i.e. Poll_home.php). When server see url file is html it will not execute it but send it content to user browser. so rename your file and check. It should work.

    点赞 打赏 评论
  • dongxiezhi0590 2018-08-10 03:06

    if isn't working with php use this

    <a href="<?='login.html';?>">login</a>

    or use this

    <a href="login.html">Login</a>
    点赞 打赏 评论

相关推荐 更多相似问题