"This webpage has a redirect loop" Error

the browser say that “This webpage has a redirect loop”
i tried to put die(); and exit(); but still the problem is still there.

what i am trying to do is when i click the link for p1_view_record.php it will check the level access and if the level access is equals to 2 it will continue to the p1_view_record.php page. if not it will go to not.php

here is my p1_view_record.php

[php]

<?php session_start(); if(!isset($_SESSION['isLogged'])){ header("location: main_login.php"); } ?> <?php session_start(); If ($_SESSION['userAccess']==2) { header("location: p1_view_record.php"); } else { header("location: not.php"); }; ?> L&K Billing System
<body>
	<div id="wrapper">
		<?php include('includes/header.php'); ?>
		<?php include('includes/nav.php'); ?>
		<div id="content">
			<h3>Product 1 Viewing Invoice</h3>
			<p>
				View invoice that was created. Please input invoice record number.
			</p>
		
			<form action="p1_view_inv.php" method="post" target="_blank">
				<fieldset>
					<div>
					<input name="inv_rec_no" type="Text" placeholder="Invoice Record Number">
					</div>
					
					<input value="View Invoice" name="submit" type="submit">
				</fieldset>
			</form>
			
		</div> <!-- end #content -->

		<?php include('includes/p1_sidebar.php'); 
		      include('includes/footer.php'); ?>

	</div> <!-- End #wrapper -->
</body>

[/php]

What is the exact error you are getting? Look at the error, it will tell you what file and what line the problem is.

I threw this script together and maybe this will help:
[php]<?php
session_start();
/* This would be part of you login in script, by that I mean /
/
grabbing the user’s access level and putting in $_SESSION */
if ( isset($_POST[‘submit’]) && $_POST[‘submit’] == ‘Submit’ ) {
$_SESSION[‘access’] = $_POST[‘level’];
}

/* This line of script would go in an utilities.inc.php or config.php file */
$user[‘access’] = (isset($_SESSION[‘access’])) ? $_SESSION[‘access’] : 5;

/* Base of User’s access level you can control where he/she goes or does */
if ( $user[‘access’] == 5 )
{
$msg = “I can’t go to my favorite website”;
}
elseif ( $user[‘access’] == 1 )
{
header(‘Location: http://www.phphelp.com’);
exit();
}

?>

<!doctype html>

Access Level

<?= (isset($msg)) ? $msg : NULL; ?>

Access Level of user
[/php]

Just remember every time you set or access $_SESSION[‘access’] (a $_SESSION variable/array) you have to have session_start();
I’m not saying you have to do this script exactly, but hopefully it will help you out.

Well thank you for your help the two of you Sir. But my codes doesn’t have any problem in my codes it is just a redirect loop. as you can see in my codes that the codes are written on the p1_view_record.php and there is a code that “if the user access is equals to 2 it will go to p1_view_record.php” in short it is a redirect loop.

I’m confused if you don’t have any problems with the code then why did you ask the question in the first place? BTW, it’s bad practice to omit the exit(); statement in your redirect code. :wink: Glad you solve your problem that wasn’t a problem? :-\

Sponsor our Newsletter | Privacy Policy | Terms of Service