Jump to content

Expert help needed!


spires
 Share

Recommended Posts

Hi,

I'm am at the final stages of finishing a large project.
I have just finished the search members and have come across a bug that i need help with.

Please take a look for yourself.
http://theeventorganiser.com/search_members.php
username - spires
password - test

The search (not logged in) works fine.
The search (when logged in) has a bug.

Whats happening is, When you click the submit button, fir some reason it logs you out.
Now, i know this because the left hand navigation changes (if session registered clause),
But, the top left says 'home | logout', if the session where destroyed this should say 'home | register | login'.

In a nut shell, when the left navi changes the top navi should also change.
Does this mean it has destroyed the sessions or not???

Can any one please help.

Here is my code.
[code]
<?php
session_start();
include('validation.php');
include('dbconnect.php');
$session_pword = $_SESSION['password'];
$session_usname = $_SESSION['username'];
?>
<?php

$set = '1';

$submit_cat = $_POST['cat'];
$get_name_sql = "SELECT * FROM category WHERE cats_id = '$submit_cat' order by cats_id DESC";
$get_name_query = mysql_query($get_name_sql) or die ("query 1 failed2");
$get_name_count = mysql_num_rows($get_name_query);
$get_name_row = mysql_fetch_array($get_name_query);
$selected = $get_name_row['cat'];

include('functions/wrapper1.php');
include('functions/dropdowns.php');
include('functions/random_images.php');
include('functions/profileLeftNavi.php');


if (isset($_POST['submit_form'])) {

$country=$_POST['country'];
$keywords=$_POST['keywords'];
$company_name=$_POST['company_name'];
$sub = $_POST['sub'];
$cat = $_POST['cat'];
$dist = $_POST['dist'];
$rep = $_POST['rep'];
$hires = $_POST['hires'];
$inst = $_POST['inst'];
$sells = $_POST['sells'];
$manu = $_POST['manu'];
$set = $_POST['set'];

$flag = 0;

$key_query = "SELECT DISTINCT id, username FROM (user_info LEFT JOIN users_categories ON user_info.id = users_categories.user_id) LEFT JOIN general_profile ON user_info.id = general_profile.profile_id LEFT JOIN availability_profile ON user_info.id = availability_profile.ava_id LEFT JOIN personal_profile ON user_info.id = personal_profile.pers_id";

if (!empty($keywords)) {
$key_query .= "
WHERE (username LIKE '%".$keywords."%' || first_name LIKE '%".$keywords."%' || last_name LIKE '%".$keywords."%' || location LIKE '%".$keywords."%' || email LIKE '%".$keywords."%' || url LIKE '%".$keywords."%' || general_profile.description LIKE '%".$keywords."%' || general_profile.history LIKE '%".$keywords."%' || general_profile.experience LIKE '%".$keywords."%' || general_profile.equipment LIKE '%".$keywords."%' || general_profile.hire_information LIKE '%".$keywords."%' || general_profile.other_requirments LIKE '%".$keywords."%'
|| availability_profile.descr LIKE '%".$keywords."%' || availability_profile.mon LIKE '%".$keywords."%' || availability_profile.tue LIKE '%".$keywords."%' || availability_profile.wed LIKE '%".$keywords."%' || availability_profile.thur LIKE '%".$keywords."%' || availability_profile.fri LIKE '%".$keywords."%' || availability_profile.sat LIKE '%".$keywords."%' || availability_profile.sun LIKE '%".$keywords."%' || personal_profile.age LIKE '%".$keywords."%' || personal_profile.religion LIKE '%".$keywords."%' ||
personal_profile.about LIKE '%".$keywords."%' || personal_profile.hobbies LIKE '%".$keywords."%' || personal_profile.education LIKE '%".$keywords."%' || personal_profile.music LIKE '%".$keywords."%' || personal_profile.Tevents LIKE '%".$keywords."%' || personal_profile.Tmag LIKE '%".$keywords."%' || personal_profile.Tradio LIKE '%".$keywords."%')";
$flag++;
}

if (!empty($country)) {
if ($flag==0) {
$key_query .= " WHERE country='$country'";
$flag++;
}else{
$key_query .= " && country='$country'";
}
}
if (!empty($company_name)) {
if ($flag==0) {
$key_query .= " WHERE company_name='$company_name'";
$flag++;
}else{
$key_query .= " && company_name='$company_name'";
}
}
if (!empty($cat)) {
if ($flag==0) {
$key_query .= " WHERE user_cats='$cat'";
$flag++;
}else{
$key_query .= " && user_cats='$cat'";
}
}
if (!empty($sub)) {
if ($flag==0) {
$key_query .= " WHERE user_subs='$sub'";
$flag++;
}else{
$key_query .= " && user_subs='$sub'";
}
}
if (!empty($sells)) {
if ($flag==0) {
$key_query .= " WHERE sales='$sells'";
$flag++;
}else{
$key_query .= " && sales='$sells'";
}
}
if (!empty($hires)) {
if ($flag==0) {
$key_query .= " WHERE hire='$hires'";
$flag++;
}else{
$key_query .= " && hire='$hires'";
}
}
if (!empty($rep)) {
if ($flag==0) {
$key_query .= " WHERE rep='$rep'";
$flag++;
}else{
$key_query .= " && rep='$rep'";
}
}
if (!empty($inst)) {
if ($flag==0) {
$key_query .= " WHERE inst='$inst'";
$flag++;
}else{
$key_query .= " && inst='$inst'";
}
}
if (!empty($manu)) {
if ($flag==0) {
$key_query .= " WHERE manu='$manu'";
$flag++;
}else{
$key_query .= " && manu='$manu'";
}
}
if (!empty($dist)) {
if ($flag==0) {
$key_query .= " WHERE manu='$manu'";
$flag++;
}else{
$key_query .= " && dist='$dist'";
}
}



$key_result = mysql_query($key_query) or die ("query 2 failed".mysql_error());
$key_count = mysql_num_rows($key_result);


}


?>
[/code]

Thanks
Link to comment
Share on other sites

Display results code

[code]
<?php
if ($key_count >= 1) {

if ($set==1) {
echo ''.$key_count.' results were found that match your search.';
  echo '<center><TABLE  width="650" border="0" cellspacing="5" cellpadding="0">';
  for ($j = 0; $j < $key_count; $j++) {
echo '<tr>';
for ($i = 0; $i < 2; $i++) {
$key_row = mysql_fetch_array($key_result);
$key_id = $key_row['id'];
$username = $key_row['username'];
$id = $key_row['id'];

$img_query = "SELECT * FROM (user_info LEFT JOIN thumb ON user_info.id = thumb.thumb_id) LEFT JOIN general_profile ON user_info.id = general_profile.profile_id  LEFT JOIN main_cats ON user_info.id = main_cats.uid WHERE user_info.id='$key_id'";
$img_result = mysql_query($img_query) or die ("query thumb failed".mysql_error());
$img_count = mysql_num_rows($img_result);

while ($img_row = mysql_fetch_array($img_result)) {
$new_img_name = $img_row['new_img_name'];
$sell1 = $img_row['sales'];
$install1 = $img_row['inst'];
$hire1 = $img_row['hire'];
$manu1 = $img_row['manu'];
$rep1 = $img_row['rep'];
$dist1 = $img_row['dist'];
$descr = $img_row['description'];
$main_cat = $img_row['main_cat'];
$main_sub = $img_row['main_sub'];

$cat_query = "SELECT * FROM category WHERE cats_id='$main_cat'";
$cat_result = mysql_query($cat_query) or die ("query thumb failed".mysql_error());
$cat_count = mysql_num_rows($cat_result);
$cat_row = mysql_fetch_array($cat_result);
$cat = $cat_row['cat'];


echo '<TD align="center">
<br><TABLE class="TLRB_border" bgcolor="#EEEEEE" width="320" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD width="120"><a href="view_profile.php?id='.$id.'" class="link">'.$username.'</a></TD>
<TD width="210" colspaan="2">Main Cat: '.$cat.'</TD>
</TR>
<TR>
<TD width="120" rowspan="5" bgcolor="#FFFFFF" align="center">
<a href="view_profile.php?id='.$id.'"><img src="thumb2/'.$new_img_name.'"></a></TD>
<TD height="70" bgcolor="#FFFFFF" colspan="2" class="TLRB_border" >'.$descr.'</TD>
</TR>
<tr>
<td width="105">SALES: '.$sell1.'</td>
<td align="left" width="105">INSTALS: '.$install1.'</td>
</tr>
<tr>
<td width="105">HIRES: '.$hire1.'</td>
<td align="left" width="105">MANU: '.$manu1.'</td>
</tr>
<tr>
<td width="105">REPAIRS: '.$rep1.'</td>
<td align="left" width="105">DIST: '.$dist1.'</td>
</tr>
</table>
</td>';
}
}
echo '</tr>';
}
echo '</table>&nbsp;&nbsp;
</center>';
}else{
echo ''.$key_count.' results were found that match your search.';
  echo '<center><TABLE  width="650" border="0" cellspacing="5" cellpadding="0">';
  for ($j = 0; $j < $key_count; $j++) {
echo '<tr>';
for ($i = 0; $i < 5; $i++) {
$key_row = mysql_fetch_array($key_result);
$key_id = $key_row['id'];
$username = $key_row['username'];
$id = $key_row['id'];

$img_query = "SELECT * FROM (user_info LEFT JOIN thumb ON user_info.id = thumb.thumb_id) LEFT JOIN general_profile ON user_info.id = general_profile.profile_id  LEFT JOIN main_cats ON user_info.id = main_cats.uid WHERE user_info.id='$key_id'";
$img_result = mysql_query($img_query) or die ("query thumb failed".mysql_error());
$img_count = mysql_num_rows($img_result);

while ($img_row = mysql_fetch_array($img_result)) {
$new_img_name = $img_row['new_img_name'];
$sell1 = $img_row['sales'];
$install1 = $img_row['inst'];
$hire1 = $img_row['hire'];
$manu1 = $img_row['manu'];
$rep1 = $img_row['rep'];
$dist1 = $img_row['dist'];
$descr = $img_row['description'];
$main_cat = $img_row['main_cat'];
$main_sub = $img_row['main_sub'];

echo '<TD align="center">
<br><TABLE class="TLRB_border" bgcolor="#EEEEEE" width="80" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD width="80">&nbsp;&nbsp;
<a href="view_profile.php?id='.$id.'" class="link">'.$username.'</a></TD>
</TR>
<TR>
<TD width="80" rowspan="5" bgcolor="#FFFFFF" align="center">
<a href="view_profile.php?id='.$id.'"><img src="thumb2/'.$new_img_name.'"></a></TD>
</TR>
</table>
</td>';
}
}
echo '</tr>';
}
echo '</table>&nbsp;&nbsp;
</center>';
}
}else{
echo 'Sorry, No results have been found.';
}
  ?>
[/code]
Link to comment
Share on other sites

Form code

[code]
<form name="form2" method="post" action="<?php echo $PHP_SELF; ?>">
                    <div align="center">
                      <table width="670" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEEEE">
                        <tr>
                          <td colspan="10">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="4" rowspan="4">&nbsp;</td>
                          <td width="87" height="26">KEYWORD:</td>
                          <td width="114"><input type="text" size="12" id="keywords" name="keywords" value="<?php echo $_POST['keywords']; ?>"></td>
                          <td width="115">COMPANY NAME: </td>
                          <td width="122" ><div align="left">
                            <input type="text" size="12" id="company_name" name="company_name" value="<?php echo $_POST['company_name']; ?>">
                          </div></td>
                          <td width="67" >COUNTRY:</td>
                          <td width="173" ><?php echo country2(); ?> </td>
                          <td width="4" rowspan="4">&nbsp;</td>
                        </tr>
                        <tr>
                          <td height="26" colspan="6" bgcolor="#CCCCCC"><div align="left">
                            <table width="539" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
                              <tr>
                                <td width="84">CATEGORY:</td>
                                <td width="165"><select name="cat" onChange="this.form.submit()">
                                  <?php
$query = "SELECT * FROM category WHERE cat != '$submit_cat' ORDER by cat ASC";
$result = mysql_query($query) or die ("query 1 failed");
$count = mysql_num_rows($result);
if(empty($cat)){
echo '<option value="0" selected>Select Category</option>';
}else{
echo '<option value='.$submit_cat.' selected>*'.$selected.'*</option>';
}

for ($i = 0; $i < $count; $i++) {
$row = mysql_fetch_array($result);
$category = $row['cat'];
$cat_id = $row['cats_id'];
    echo '<option value="'.$cat_id.'">'.$category.'</option>';

}

?>
                                </select></td>
                                <td width="147">SUB CATEGORY:</td>
                                <td width="143"><select name="sub">
                                  <?php


$query1 = "SELECT * FROM cats_sub INNER JOIN categories ON cats_sub.subs_id = categories.id WHERE categories.cat_id = '$submit_cat' ORDER by sub ASC";
$result1 = mysql_query($query1) or die ("query 3 failed");
$count1 = mysql_num_rows($result1);

if(empty($cat)){
echo '<option value="0" selected>Select Category</option>';
}else{
echo '<option value="0" selected>select item</option>';
}
while ($row1 = mysql_fetch_array($result1)) {
echo '<option value="'.$row1['sub_id'].'">'.$row1['sub'].'</option>';
}
?>
                                </select></td>
                              </tr>
                            </table>
</div>
                            </td>
                          </tr>
                        <tr>
                          <td height="26" colspan="6"><div align="center">SELLS:
                                <input type="checkbox" name="sells" value="Yes">
                              &nbsp;|
                              HIRES:
                              <input type="checkbox" name="hires" value="Yes">
                              &nbsp; |
                              REPAIRS:
                              <input type="checkbox" name="rep" value="Yes">
                              &nbsp; |
                              INSTALLATIONS:
                              <input type="checkbox" name="inst" value="Yes">
                              &nbsp; |
                              MANUFACTURES:
                              <input type="checkbox" name="manu" value="Yes">
                              &nbsp; |
                              DISTRIBUTES:
                              <input type="checkbox" name="dist" value="Yes">
                          </div></td>
                          </tr>
                        <tr>
                          <td colspan="5" rowspan="2"><div align="left">
  <?php
  if ($set==1) {
  echo '&nbsp;|&nbsp; MORE INFO:&nbsp;
                                <input type="radio" name="set" value="1" checked>
&nbsp;|&nbsp; THUMBNAILS:&nbsp;
<input type="radio" name="set" value="0">';
}else{
echo '&nbsp;|&nbsp; MORE INFO:&nbsp;
                                <input type="radio" name="set" value="1">
&nbsp;|&nbsp; THUMBNAILS:&nbsp;
<input type="radio" name="set" value="0" checked>';
}
?>
                            </div></td>
                          <td rowspan="2"><input name="submit_form" type="submit" value="submit"></td>
                        </tr>
                        <tr>
                          <td rowspan="6">&nbsp;</td>
                          <td width="4" rowspan="6">&nbsp;</td>
                        </tr>
                      </table>
                    </div>
                </form>
[/code]
Link to comment
Share on other sites

No not yet,

try logging in then goto the search member page (link on the left navi)
Then take a mental note of all of the left navi box.
PERSONAL and MEMBERS DETAILS.

Now tick SELLS (it will do the same with almost every combination)
then click submit.

You'll notice that the left navi no longer has PERSONAL and MEMBERS DETAILS.
Which must mean the session has been destroyed.
however the top navi still says 'logout' which means the session cant have been destroyed?

Very strange.

Any more help would be great thanks
Link to comment
Share on other sites

Where is the code for the side nav that checks if your logged in or not?
I'd compare the codes in your header and in your left navigation.

Also, it appears your session is being destroyed because if you then try to view "My Account" (I copied the link before it disappeared) it takes you to the login form.
Link to comment
Share on other sites

here is the functions

[code]
function view_details($view_id) {
$wrapperuser = $_SESSION['username'];
$sql="SELECT * FROM user_info INNER JOIN viewed ON user_info.id = viewed.user_id WHERE user_info.id='$view_id'";
$result = mysql_query($sql) or die ('Could not connect');
$count = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$id = $row['id'];
$uname = $row['username'];
$date = $row['date'];
$view = $row['view'];

$sql="SELECT * FROM comments WHERE contact_id='$view_id'";
$result = mysql_query($sql) or die ('Could not connect1');
$count = mysql_num_rows($result);

$sql = "SELECT * FROM main_cats WHERE uid='$id'";
$query = mysql_query($sql) or die (mysql_error());
$count = mysql_num_rows($query);
$row = mysql_fetch_array($query);
$main_sub = $row['main_sub'];
$main_cat = $row['main_cat'];

$sql1 = "SELECT * FROM category INNER JOIN cats_sub WHERE cats_sub.subs_id='$main_sub' and category.cats_id='$main_cat'";
$query1 = mysql_query($sql1) or die (mysql_error());
$count1 = mysql_num_rows($query1);
$row1 = mysql_fetch_array($query1);
$cat = $row1['cat'];
$sub = $row1['sub'];

echo '<BR><TABLE cellpadding="0" cellspacing="0" border="0" width="182">
<TR>
<TD width="182" height="20" bgcolor="#0000FF" valign="bottom">
<img src="JPGS/tags/details.jpg">
</TD>
</TR>
<TR>
<TD width="182" class="TLRB_border" bgcolor="#EEEEEE">';
echo '
&nbsp;&nbsp;USER - <span class="error">'.$uname.'</span><br>
&nbsp;&nbsp;JOINED - <span class="error">'.$date.'</span><br>
&nbsp;&nbsp;VIEWS - <span class="error">'.$view.'</span><br>
&nbsp;&nbsp;COMMENTS - <span class="error">'.$count.'</span><br>
&nbsp;&nbsp;MAIN CAT - <span class="error2">'.$cat.'</span><br>
&nbsp;&nbsp;SUB CAT - <span class="error2">'.$sub.'</span><br>
';

echo '</TD>
</TR>
</TABLE>';

}



function personal() {
if(!isset($_SESSION['username'])) {

} else {
$wrapperuser = $_SESSION['username'];
$sql_id = "SELECT * FROM user_info WHERE username='$wrapperuser'";
$query_id = mysql_query($sql_id) or die ('Could not connect1');
$row_id = mysql_fetch_array($query_id);
$id = $row_id['id'];
echo '<BR><TABLE cellpadding="0" cellspacing="0" border="0" width="182">
<TR>
<TD width="182" height="20" bgcolor="#0000FF" valign="bottom">
<img src="JPGS/tags/personal.jpg">
</TD>
</TR>
<TR>
<TD width="182" class="TLRB_border" bgcolor="#EEEEEE">';
    echo '&nbsp;&nbsp;&nbsp;&nbsp;- <a href="login.php">MY ACCOUNT</a><br><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_contacts.php?id='.$id.'">MY CONTACTS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_messages.php">MY MESSAGES</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_comments.php?id='.$id.'">MY COMMENTS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_news.php">MY NEWS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_jobs.php?id='.$id.'">MY JOBS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="gallery.php">MY GALLERY</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_cats.php?id='.$id.'">MY CATEGORIES</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="my_banner.php?id='.$id.'">MY BANNERS</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="account_balance.php">MY ACCOUNT BALANCE</a><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;- <a href="edit.php?id='.$id.'">EDIT PROFILE</a><br>';
echo '</TD>
</TR>
</TABLE>';
}
}
[/code]

left navi
[code]
function display_not_loggedin_() {
if(isset($_SESSION['username'])) {
menu();
$personal = personal();
$details = details();
latest_members();
latest_jobs();
$admins = admins();
} else {
menu();
latest_members();
latest_jobs();
}
}
[/code]

here is logout
[code]
function topLinks() {
session_start();
if(!session_is_registered(username)) {
echo '<div align="center"><a href="index.php" class="crumbslink">HOME</a> - <a href="register.php" class="crumbslink">REGISTER</a> - <a href="login.php" class="crumbslink">LOGIN</a></div>';
}else{
echo '<div align="center"><a href="index.php" class="crumbslink">HOME</a> - <a href="logout.php" class="crumbslink">LOGOUT</a></div>';
}
}
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

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.

 Share

×
×
  • 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.