Jump to content

please help me find my problem


chris_s_22

Recommended Posts

 

What else can i do to narrow down and solve the problem.

 

Where is my problem?

1}When i go to my search index page which displays a search form.

2)The data from form is sent to the search.php for checking and displays results without a problem.

3)If i then navigate to another page other than the result links everything is fine

 

HOWEVER.. if i click on one of the result links, it let me navigate to the page and displays fine

but doesnt let me navigate away from that page. The session just seems to end

so when i try visit any other page it fails on the is_authed function

 

the is_authed function checks session data.

 

THIS IS THE PAGE THAT RESULTS LINKS ARE DIRECTED TO

<?php
include_once 'Connect.php';
if (!is_authed()) 
{
     die ('You are not permitted to view this page, <a href="index.php">click here</a> to go back.');
}
?>
<html><head>
<link href="style.css" rel="stylesheet" type="text/css"></head>
<body>
<div class=logo><?php include "logo.php";?></div>
<div class=navigationbarbox><?php include "navigationbar.php";?></div>
<div class=photo><?php include "profilephoto.php";?></div>
<div class=sidelinks><?php include "profilesidelinks.php";?></div>
<div class=info><?php include "profileinfo.php";?></div>
<div class=footerbox><?php include "footer.php";?></div>
</body></html>

MY SESSION IS THE FIRST THING IN CONNECT.PHP which also conect to database and calls for any functions needed.

the logo just contains <img src="images/logo.jpg"  alt="" width="300" height="65"> no php whatso ever

the navigation contains my navigation bar this includes connect.php

profilesidelinks as the names says is side bar link also inlcudes connect.php

profileinfo includes connect.php and just queries database and displays info

footer as the name suggest is the footer with links no php whatso ever

Link to comment
Share on other sites

after more checking i realise if i echo out session data its fine

unless it came from the search results the session username is changed

 

So im guessing that my problem is in search.php that somewhere i change the session username

so the data been passed to the view.php is wrong

 

This is the search.php

 
<?php include 'Connect.php';?>
<html><head><link href="style.css" rel="stylesheet" type="text/css"></head>
<body>
<div class=navigationbarbox><?php include "navigationbar.php";?></div>
<?php
if(!isset($_GET[submit])) 
{
     // Show the form
     include 'searchindex.php';
     exit;
} 
else 
{
    if (empty($_GET['searchone']) )// Check if field empty
{
	// Reshow the form with an error
    	$searchempty_error = 'field empty';
    	include 'searchindex.php';
    	exit;
}
//CHECKS USERNAME
if(!preg_match("/^[a-z\d]{1,100}$/i", $_GET[searchone]))
{
	// Reshow the form with an error
    	$searchentery_error = "Invalid search only letters and numbers!<br />";
	include 'searchindex.php';
    	exit;  
}
$result = mysql_query ("SELECT * FROM members WHERE username LIKE '%$searchone%' "); 
    $num=mysql_num_rows($result);

    if($num>0) 
{
        /* start the search result box */
        echo '<div class="searchresults">';
	echo "<table><tr>";
        while($row=mysql_fetch_array($result)) 
	{
		$userid = $row["id"];
		$photo = $row["photo"];
		echo "<td><img src='http://myurl.co.uk/NEWTEACH/userimages/$photo' width='100' height='150'><br>";
		echo '<a href="profileindex.php?userid='.$userid.'">' . $row['username'] . '</a><br>';
            echo '<strong>Location:</strong>' . $row['location'] . '<br>';
            echo '<strong>Date of Birth:</strong>' . $row['dob'] . '</td>';
    	} 
	echo "</tr></table>";
        echo '</div>'; //end searchresults div
} 
	else 
	{
        echo '<p>Sorry, your search returned no results!</p>';
	}  // end if $num

} // end isset if 
?> 
<div class=searchresult><?php 
echo '<strong>You searched for:</strong> ' . $searchone . '<br>';
    echo 'There are ' . $num . ' results.';
?></div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.