Jump to content

seasons grrrrrrrr !


andrew_biggart

Recommended Posts

Ok i know this is a simple problem but its really doing my head in aghhhh...

 

for all my page links i want the url to be test.php?username=seasonusername

 

its really pissing me off

 

ive tried it ways like this test.php?username=<?php echo " ".$_SESSION["myusername"]. " "; ?>

 

but i just cant get it to work please help

Link to comment
https://forums.phpfreaks.com/topic/147322-seasons-grrrrrrrr/
Share on other sites

Define: cant get it to work. What is it doing?

 

For all we can tell, based on the non-information you provided in your post, your sessions are not working and $_SESSION["myusername"] in empty.

 

The only way anyone can help you is if you provide the relevant information about what you saw in front of you.

 

Edit: and if you already have the username in a session, there is no point in putting it onto the end of the URL to pass it to a page. Just use the session variable on that page.

 

 

Link to comment
https://forums.phpfreaks.com/topic/147322-seasons-grrrrrrrr/#findComment-773293
Share on other sites

When i click on the link to say homepage.php an i have used the above code in the like, it will display hopepage.php?username=(blank) but i know my seasons are working because the pages are protected like this.

 

<?php
session_start();
if(!session_is_registered(myusername)){
header("index.php");
}
?>

 

my check login page is usuing this code and i know it is definitly creating the right season.

 

	<?php
	include("config_members.php");

	// username and password sent from form 
	$myusername=$_POST['myusername']; 
	$mypassword=$_POST['mypassword']; 

	// To protect MySQL injection (more detail about MySQL injection)
	$myusername = stripslashes($myusername);
	$mypassword = stripslashes($mypassword);
	$myusername = mysql_real_escape_string($myusername);
	$mypassword = mysql_real_escape_string($mypassword);

	$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
	$result=mysql_query($sql);
	$row = mysql_fetch_assoc($result);

	// Mysql_num_row is counting table row
	$count=mysql_num_rows($result);
	// If result matched $myusername and $mypassword, table row must be 1 row

	if($count==1){
	// Register $myusername, $mypassword and redirect to file 
	session_register("myusername");
	session_register("mypassword"); 
	$_SESSION['myusername'] = $myusername;
      header("location:my_profile.php?username=$myusername");
	exit();
      }
      else {
      echo "<h1 class=login_status>Wrong Username or Password</h1>";
      }
   	?>

 

and when a user logs in there are automatically redirected to the myprofile.php page where which uses this code to display the profile.

 

	<?php

include("config_members.php");
$username=$_GET['username'];

// Retrieve data from database 
$sql="SELECT * FROM User_infoT WHERE Username='$username'";
$result=mysql_query($sql);

// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
<table class="login_table" cellspacing="0" cellpadding="0">
<tr><td class="profilepicture"><img class="profile_pic"alt="" src="../Profile_pics/admin_pp.jpg" width="100" height="100" /></td></tr>
<tr><td class="myprofile_welcome">Hi, <?php if(isset($_SESSION['myusername']) == True) { echo " ".$_SESSION["myusername"]. " ";} else {} ?></td>
</tr>
<tr><td></td></tr>
<tr><td class="myprofile_welcomeback">Welcome to the weloveweed mansion.</td></tr>
<tr><td class="myprofile_welcomeback">Make sure & stick to the rules & most of all have fun.</td></tr> 
</table>
</div>
<div id="new_recipes_header" style="left: 0px; top: 0px">
<h1 class="procats" style="font-weight: normal">Personal Info</h1>
</div>
<div id="new_recipes">
<table style="width: 100%" cellspacing="0" cellpadding="0">
<tr><td class="proinfo_h">Interests</td></tr>
<tr><td class="proinfo"><? echo $rows['Interests']; ?></td></tr>
<tr><td class="proinfo_h">Makes me happy</td></tr>
<tr><td class="proinfo"><? echo $rows['Happy']; ?></td></tr>
<tr><td class="proinfo_h">Makes me sad</td></tr>
<tr><td class="proinfo"><? echo $rows['Sad']; ?></td></tr>
<tr><td class="proinfo_h">Bad Habits</td></tr>
<tr><td class="proinfo"><? echo $rows['Habits']; ?></td></tr>
</table>
</div>
<div id="new_members">
<h1 class="procats" style="font-weight: normal">Favourite Things</h1>
<table style="width: 100%" cellspacing="0" cellpadding="0">
<tr><td class="proinfo_h">Music</td></tr>
<tr><td class="proinfo"><? echo $rows['Music']; ?></td></tr>
<tr><td class="proinfo_h">Movie</td></tr>
<tr><td class="proinfo"><? echo $rows['Movie']; ?></td></tr>
<tr><td class="proinfo_h">Website</td></tr>
<tr><td class="proinfo"><a class="profile_site" href="<? echo $rows['Website']; ?>">click hear to view</a></td></tr>
</table>
<br />
</div>

 

but i want to be able to put the username like this myprofile.php?username=(season myusername) so that i can put it there at anytime and by usuing the season one for like posting comments replies etc etc

 

hopefully this explains it alot better, i am a beginer so sorry for my lack of experience lol

Link to comment
https://forums.phpfreaks.com/topic/147322-seasons-grrrrrrrr/#findComment-773300
Share on other sites

Each page (URL) that sets or uses a session variable must have a session_start() statement.

 

session_is_registered and session_register should not be used at all because they were depreciated and turned off as of php4.2 in the year 2002 when register_globals where turned off (if you have register_globals on and any of your code is dependent on them, you are in for a rude surprise when your code stops working under php6 and must be rewritten to not use register_globals or session_is_registered and session_register) and they should not be used at same time as $_SESSION variables.

Link to comment
https://forums.phpfreaks.com/topic/147322-seasons-grrrrrrrr/#findComment-773323
Share on other sites

how about storing the username alone in a cookie ? then calling it using $_COOKIE['username'] .....?

 

also I only saw one place where you were trying to forward the username to another url via GET.

header("location:my_profile.php?username=$myusername");

 

is there anywhere else? How are you trying to implement...

 

test.php?username=<?php echo " ".$_SESSION["myusername"]. " "; ?> 
//maybe toss this line in your code where you have some html.....like this:

?>

</tr>
<tr><td><a href="test.php?username=<?php echo " ".$_SESSION["myusername"]. " "; ?>">THIS IS YOUR LINK</a></td></tr>
<tr><td class="myprofile_welcomeback">Welcome to the weloveweed mansion.</td></tr>

 

 

PS- I see you keep typing seasons.....do you mean sessions?

 

Link to comment
https://forums.phpfreaks.com/topic/147322-seasons-grrrrrrrr/#findComment-773374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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