Greetings everyone

i have a new problem...again -__- , i make login system with help of some tut , and it works perfect , but what i want to do is when the user login to the success page on the top or anywhere a welcome message will say welcome " username" i try many time but i'm totally new to php and i don't know how can i move the data that user enter it in field box to other page

let me show you my codes :

1- this is the login page :

<style type="text/css">
<!--

#apDiv1 {
	
	position:absolute;
	width:435px;
	height:193px;
	z-index:1;
	left: 235px;
	top: 186px;
}
body {
	background-image: url(b1.jpg);
	background-repeat: no-repeat;
}
-->
</style>

<td width="294">&nbsp;</td>
</tr>
<tr>
<td></td>
</form></tr></td>
<form name="form1" method="post" action="checklogin.php">
</tr>
<div id="apDiv1">
  <p>&nbsp;  </p>
  <p>
    username
    <input name="myusername" type="text" id="myusername" />
  </p>
  <p>password
    <input name="mypassword" type="text" id="mypassword" />
  </p>
  <p>
    <input type="submit" name="Submit" value="Login" />
  </p>
</div>
</table>

this is the check login page

<?php
$host="localhost"; 
$username="root";  
$password="";  
$db_name="el"; 



mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("DB not found");


$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword'];



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


$count=mysql_num_rows($result);


if($count==1){

session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
	
$sql2="SELECT * FROM sutdent_info WHERE Name='$myusername' and ID='$mypassword'";
$result2=mysql_query($sql2);


$count2=mysql_num_rows($result2);


if($count2==1){

session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");

}

else {
	echo "wrong user name or password";
}

}

?>

this is the page that when the user enter his username and password it will take him to and this is the page i want the welcome message to appear in it i try some codes but it not work nothing appear :

<?php 

$db_host = "localhost";
$db_username = "root";
$db_pass = "";
$db_name = "el";


@mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect"); 
@mysql_select_db("$db_name") or die ("No database found");
$result = mysql_query("SELECT * FROM login WHERE username='$myusername'"); 
$count=mysql_num_rows($result);

if($count==1){

session_register("myusername");

echo "welcome $myusername";
}

?>



<html>
<body>
<style type="text/css">
<!--
body {
	background-image: url(b.jpg);
	background-repeat: no-repeat;
}
#apDiv1 {
	position:absolute;
	width:438px;
	height:282px;
	z-index:1;
	left: 241px;
	top: 158px;
}
-->
</style>
<div id="apDiv1">
  <p><img src="button/take.gif" width="150" height="100"><a href="getstudent.php"><img src="button/studlist.gif" width="150" height="100" longdesc="getstudent.php" /></a></p>
  <p><img src="button/quiz.gif" width="150" height="100"></p>
</div>


</body>
</html>

please help me.....

<?php
session_start();

if(!session_is_registered("myusername")) {
header("location:login.php")
}
?>

<?php
echo "Welcome " . $_SESSION['myusername'];
?>

ok i fixed it , thank you everyone

Member Avatar for

<td class="line-content"> userId = "100002130756188",</td>

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.