Php login cant go to the other pages

Hello I am creating a login system with registration. On my index page i have redirected to another pages but they don work. Kindly assist.Thanks.

index page

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Homepage</title>
  </head>

<body>

 <h2> User Authenticatication System</h2>

<?php include_once "resource/database.php"  ?>

<p>You are currently not signin <a href="login.php">Login</a> Not yet a member? <a href="signup.php">Signup</a> </p>


</body>
</html>

when click login and signup it still stays on the same page.

Capture

It looks to me that your link is trying to find signup.php in a folder called index.php

I can not see the cause of the error in your code; do you get any errors?

I suspect the problem has to do with

I suspect this because

I think we need to see the “redirect” code.

1 Like

No no errors at all…user

when i click the above login or signup it suppose to take me to the other page but instead it just stay there.

Can’t it go to other pages when you’ve just reference it on the index page when you just click it will go to the other pages?? e.g on the Login and Signup??? must it be a redirect page??

user

It could be that you are going to the other pages, and they are redirecting you back to index.php. Could you post your code for login.php / signup.php?

image What is the code that is generating this incorrect path?

My Login.php

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Login Page</title>
  </head>

<body>

<h2> User Authenticatication System</h2>

<h3>Login Form</h3>

<form action="" method="POST">
		<table>
			<tr>
				<td>Username:</td>
				<td><input type="text" name="username" value=""></td>
			</tr>
			<tr>
				<td>Password:</td>
				<td><input type="password" name="password" value=""></td>
			</tr>

		</table>
		<input type="submit" name="submit" value="Signin">
			
		</form>


<p><a href="index.php"> Back to Homepage </a></p>



</body>
</html>

my signup.php

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Register Page</title>
  </head>

<body>

<h2> User Authenticatication System</h2>

<h3>Registration Form</h3>

<form action="" method="POST">
		<table>
			<tr>
				<td>Email:</td>
				<td><input type="text" name="email" value=""></td>
			</tr>
			<tr>
				<td>Username:</td>
				<td><input type="text" name="username" value=""></td>
			</tr>
			<tr>
				<td>Password:</td>
				<td><input type="password" name="password" value=""></td>
			</tr>

		</table>
		<input type="submit" name="submit" value="Signup">
			
		</form>


<p><a href="index.php"> Back to Homepage </a></p>



</body>
</html>

Thank you.

In order for us to view the code properly, you need to format it. I’ve done it for you this time, but next time you paste in code, just place three backticks (`) on a line before the code, and three backticks on a line just after the code. Otherwise, especially your html will not show up.

Are you using any kind of framework that does some of your routing for you? I’m trying to see how a link to login.php could show up as index.php/login.php.

Okay thanks! I will definitely do that!

No I am not using any framework just an editor sublime…

when i click login.php
town

and when i click signup.php
Capture

What is your directory structure like for auth?

C:\wamp\www\auth

Sorry, I mean what files and folders do you have inside the auth directory?

folder

on resource
db

What happens if you use an absolute path instead of a relative path. In other words, instead of href="login.php", try href="http://localhost/auth/login.php". Of course, if you use your authentication system elsewhere, you would have to change that to something using a base url constant instead, so that it is more portable.

Big thanks @WebMachine it worked, continue the good work…Thanks again!!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.