i were working offline all the time with wampserver installed in my comp.
but after i loaded it in school server i experienced a problem,
in my web after login in your own profile appears also their is a link were you see other members profile.
My problem is that when you open other profile and tend to open again(myprofile)your own profile which is also as a link after opening another profile.
some of the datas of the other member especialy the last registered member appears on myprofile,while offline i didn`t have such a problem.
How can i overcome this???????????

Recommended Answers

All 11 Replies

i were working offline all the time with wampserver installed in my comp.
but after i loaded it in school server i experienced a problem,
in my web after login in your own profile appears also their is a link were you see other members profile.
My problem is that when you open other profile and tend to open again(myprofile)your own profile which is also as a link after opening another profile.
some of the datas of the other member especialy the last registered member appears on myprofile,while offline i didn`t have such a problem.
How can i overcome this???????????

Someone might be able to help you if they could see the actual problem, line of code,

That's strange. Is there any change of version in php/apache ? I can't think of a reason why your script is acting weirdly !

Schools do not often secure properly other users directories and once you login into system you able to browse other users work, this is just side observation

there is no change in php/apache.
i`m suprised because offline it works well.

This is the script i used to login:

<html>
<head>

<title>Welcome|To our site</title></head>
<body bgcolor=black>
<?php
//header( 'refresh: 5; url=http://localhost/website/member.php' );

$user=$_POST['user'];
 $password=($_POST['password']);
 

//connecting to databases
$dbcnx=@mysql_connect('localhost','root','*********');
 if(!$dbcnx){
 exit('<p>unable to connect to the database'.
      ' this time try again later.</p>');
	  }
	  
if (!@mysql_select_db('register')){
	   exit('<p>unable to locate the REGISTER DATABASE'.
	   'AT THIS TIME');
	   }
 //makes sure they filled it in
if(!$_POST['user'] | !$_POST['password']) {
echo "<center><font color=white size=12>Either pass or UserName are not filled<br><a href=peacemaker.php>Go back and try again</a></font></center>";
}else{

session_start();	   
$query = "SELECT  *FROM login where (user='$user' and password='$password')" ;
$result=mysql_query($query);
if(mysql_num_rows($result) == 1) {
      
$row=mysql_fetch_array($result);
$id=$row['id'];
$name=$row['name'];
$user=$row['user'];
$email=$row['email'];
$country=$row['country'];
$password=$row['password'];
$location=$row['location'];
$langu1=$row['langu1'];
$langu2=$row['langu2'];
$family=$row['family'];
$education=$row['education'];
$age=$row['age'];
$male=$row['male'];
$female=$row['female'];
$hobbie=$row['hobbie'];
$phone=$row['phone'];
$address=$row['address'];
$web=$row['web'];
$relation=$row['relation'];
$position=$row['position'];
$movies=$row['movies'];
$date=$row['date'];

$_SESSION['id']=$row['id'];
$_SESSION['name']=$row['name'];
$_SESSION['user']=$row['user'];
$_SESSION['email']=$row['email'];
$_SESSION['country']=$row['country'];
$_SESSION['password']=$row['password'];
$_SESSION['location']=$row['location'];
$_SESSION['langu1']=$row['langu1'];
$_SESSION['langu2']=$row['langu2'];
$_SESSION['family']=$row['family'];
$_SESSION['education']=$row['education'];
$_SESSION['age']=$row['age'];
$_SESSION['male']=$row['male'];
$_SESSION['female']=$row['female'];
$_SESSION['hobbie']=$row['hobbie'];
$_SESSION['phone']=$row['phone'];
$_SESSION['address']=$row['address'];
$_SESSION['web']=$row['web'];
$_SESSION['relation']=$row['relation'];
$_SESSION['position']=$row['position'];
$_SESSION['movies']=$row['movies'];
$_SESSION['date']=$row['date'];



include "myprofile.php";
}else{
 include "login_Bad.php";
 }
}

?>
</td></tr></table>
</table>
</body>
</html>

and the myprofile.php is here:
<html>
<head>
<?php
 header( 'refresh:5;  url=http://localhost/website/myprofile.php' );

 //header("Location: http://localhost/website/myprofile.php");
// header( 'refresh: 5; url=http://localhost/website/myprofile.php' );

session_start();
$id=$_SESSION['id'];
$name=$_SESSION['name'];
$user=$_SESSION['user'];
$email=$_SESSION['email'];
$country=$_SESSION['country'];
$password=$_SESSION['password'];
$location=$_SESSION['location'];
$langu1=$_SESSION['langu1'];
$langu2=$_SESSION['langu2'];
$family=$_SESSION['family'];
$education=$_SESSION['education'];
$age=$_SESSION['age'];
$male=$_SESSION['male'];
$female=$_SESSION['female'];
$hobbie=$_SESSION['hobbie'];
$phone=$_SESSION['phone'];
$address=$_SESSION['address'];
$web=$_SESSION['web'];
$relation=$_SESSION['relation'];
$position=$_SESSION['position'];
$movies=$_SESSION['movies'];
$date=$_SESSION['date'];

?>

<title>welcome| <?php echo$user?></title></head>
<body bgcolor=black>
<table width=646 height=30  align=center border=0 background=COMD.jpg cellspacing=8 cellpadding=2 >
<TR><td><img src=SOMA.jpg width=601 height=50></td></tr>
</table>


<table width="646" border="0" cellpadding="2" background="bg-header.jpg" cellspacing="2"  ALIGN=CENTER borderclor=red>
<tr valign="top">
<td><br><b><a href=home2.php>HOME</a></b>
</td>
<td><br><b><a href=myprofile.php>MYPROFILE</a></b>
</td>
<td><br><b><a href=comment.php>COMMENTS</a></b>
</td>
<td><br><b><a href=member2.php>MEMBERS</a><b>
</td>
<td><br><b><a href=comedy.php>COMEDY</a></b>
</td>
<td><br><b><a href=photo/index.html>PHOTOS</a></b>
</td>
<td><br><b><a href=music.php>MUSIC</a></b>
</td>

<td><br><b> <form action=logout.php method=get><input type=submit value="LOGOUT" ></form></b>
</td>


</tr>
</table>


<table width=646 height=20  align=center border=0  bgcolor=gainsboro   cellspacing=8 cellpadding=2>
<TR VALIGN=TOP>
<td WIDTH=20 height=10>
<TABLE width=20 bgcolor=lightblue  border=1 cellpadding=0 cellspacing=0 align=left height=10 bordercolor=black>
<tr align=top><td ><B><br><a href=myprofile.php>FRIENDS</a></B></td></tr><tr VALIGN=TOP><td><B><br><a href=myprofile.php>MY PHOTO</a></B></td></tr><tr><td><B><br><a href=myprofile.php><NOBR>MESSAGE</NOBR></a></B></td></tr><tr><td><B><br><a href=edit.php>SETTING</a></B></td></tr>
<tr><td><B><br><a href=myprofile.php>MY VIDEO</a></B></td></tr><tr><td><B><br><a href=myprofile.php>REQUEST</a></B></td></tr><tr><td><B><br><a href=myprofile.php><nobr>WHO VISITED</nobr></a></B> </td></tr><tr><td><B><br><a href=invite.php>INVITE</a></B></td></tr></table>
</td><td width=80 align=center><P><b>Helloo!!</b><?php echo"<font size=3 color=brown><b><nobr>$user</b></font>";?></nobr></p><p align=center><img src=man.jpg width=140 height=150></p>
<table width=80 height=10 border=1  cellspacing="1" cellpadding=1 bordercolor=black>
<caption><nobr><b><font color=brown>MORE ABOUT ME</font></b></nobr></caption>
<tr><td valign=top width=200 height=10>
<p><b>Name:</b><?php echo"<font color=blue><b>$name $family</b></font>"; ?></p><p><nobr><b>Email:</b><?php echo "<font color=blue><b>$email</b></font>"; ?></nobr></p><p><b>Address:</b><?php echo "<font color=blue><b>$address</b></font>";?></p><p><b>Language:</b><?php  echo"<font color=blue><b>$langu1</b></font>,<b><font color=blue> $langu2</b></font>";?></p><p><b>POSITION:</b><?php echo "<font color=blue><b>$position</b></font>";?></p>
<p><b>Hobbie:<b><?php echo "<font color=blue><b>$hobbie</b></font>";?></p><p><b>Phone:</b><?php echo"<font color=blue>$phone</font>";?></p><p><b>Web:</b><?php echo "<font color=blue>$web</font>";?></p><p><nobr><b>Favorite Music:</b><?php echo "<font color=blue>$music</font>";?></nobr><nobr><b>Favorite Movies:</b><?php echo "<font color=blue>$movies</font>";?></p>
</td></tr>
</table>

</td><td><p><font color=yellow><b>Browse with pleasure</b></font></p><p><table width=100 height=100 border=0  cellspacing="1" cellpadding=1>
<tr><td valign=top><b>Gender:</b></td><td valign=top><b>Age:</b></td></tr>
<tr align=><td valign=top align=><?php echo "<font color=blue><b> $male $female</b></font>";?></td><td valign=top><?php echo"<font color=blue><b>$age</b></font>";?></td></tr><tr><td valign=top><nobr><b>location:</b></nobr></td><td valign=top><nobr><b>Nationality:</b></nobr></td></tr><tr><td valign=top><nobr><?php echo"<font color=blue><b>$location</b></font>"?></nobr></td><td valign=top><?php echo "<font color=blue><b>$country</b></font>";?></td></tr>
<tr align=center><td valign=top><nobr><b>Member Since:</b></nobr></td><td valign=top><nobr><b>Relation status:</b></nobr></td></tr>
<tr ><td valign=top><nobr><?php echo"<font color=blue><b>$date</b></font>";?></nobr></td><td valign=top><?php echo "<font color=blue><b>$relation</b></font>";?></td></tr>
</table></p><hr font color=black></hr>



</td>


</TR>
</table>

</body>
</html>

Its very difficult to say what is going wrong. Try unsetting the session variables and see if it does any trick.

do you mean at the end of my session??
should i put something like this:
session_unset();

Umm.. When you visit someone's profile, will his details be added to the session ? If yes, then unset the session variables before using it again. If no, then, I can't think of anything else.

when you visit somone`s profile,his Details are not added to the sessions))
this real suprises me and i just noticed that is the last registered person which details troubles.

Hmm.. I don't have a clue.. :(

You have http://localhost hardcoded in your script, use the host name of the web server.

This would explain why it works on your workstation but not the server. When you have no session data it's because you've been transferred to the web server running on your workstation, and the session data is on the remote server, so php doesn't see it.

To find it all, shut down the server running locally and you'll get 404's wherever you have a hardcoding.

To avoid this use:

header( "refresh:5; url=http://{$_SERVER['SERVER_NAME']}/website/myprofile.php" );

or

header( "refresh:5; url=/website/myprofile.php" );

instead of

header( 'refresh:5; url=http://localhost/website/myprofile.php' );

Either works...

Hardcoding host names in links will always cause broken scripts so never do it unless you are going to a different host and there is no other way 8)

I learned this from working in a disciplined environment where we had:
www.servername.com
qual.servername.com
dev.servername.com

Hardcoding caused the qa guys to get completely broken sites. You learn really fast when it takes a week of red tape to get changes moved, then another week to get the fixes put in to fix your hardcodings ROFL.

commented: Thats a nice point.. +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.