NojanServer
Member
آقا مي يك ديتابيس دارم و يك برنامه Login مي خوام كاري كنم كه وقتي كاربر وارد ميشه بعد از ورود بالاي صفحه نام كاربري بخوره ، مثل همين جا كه از نام كاربري من وارد شده و كنارش خوش آمديد هم درج شده .....
يك كمك كنيد
يك كمك كنيد
mosi20 گفت:توی یک صفحه که بالای همه ی صفحاتت تکرار میشه یه متغییر تعریف میکنی که یوزیرنم کاربر باشه
<?
///////////////////////////////////////////////////////////////////////////////////////
// In the name of God //
// This portal is a private portal And it was writen by Mohsen Davari //
// Please do not change its copyright //
// I hope that you enjoy using my portal //
// If you have any problem contact me with this email => [email protected] //
// Thank`s a lot //
// Bye //
///////////////////////////////////////////////////////////////////////////////////////
// include inc.php for keeping your session in correct way //]
require("inc.php");
//conect to mysql and get the username//
//mysql host name//
$DBHOST = "localhost";
//database username//
$DBUSER = "";
//database password//
$DBPASS = "";
//database name//
$DBNAME = "";
//Connect to mysql//
mysql_connect($DBHOST, $DBUSER, $DBPASS) or die(mysql_error());
//Connect to database//
mysql_select_db($DBNAME) or die(mysql_error());
if(!isset($_SESSION['username'])){
if(isset($_POST['username'])){
//conect to your table for example users table//
$result =mysql_query("SELECT * FROM users WHERE username='{$_post['username']}'") or die(mysql_error());
$row = mysql_fetch_array( $result );
// creat some session if this username exit//
if (mysql_num_rows($result) > 0) {
$_SESSION['username'] = $_POST['username'];
}else{
print'this username does not exit';
}
}
}
//here you can put your other php code//
?>
<?
///////////////////////////////////////////////////////////////////////////////////////
// In the name of God //
// This portal is a private portal And it was writen by Mohsen Davari //
// Please do not change its copyright //
// I hope that you enjoy using my portal //
// If you have any problem contact me with this email => [email protected] //
// Thank`s a lot //
// Bye //
///////////////////////////////////////////////////////////////////////////////////////
//keep the session in safe and correct way//
session_start();
?>
<?
///////////////////////////////////////////////////////////////////////////////////////
// In the name of God //
// This portal is a private portal And it was writen by Mohsen Davari //
// Please do not change its copyright //
// I hope that you enjoy using my portal //
// If you have any problem contact me with this email => [email protected] //
// Thank`s a lot //
// Bye //
///////////////////////////////////////////////////////////////////////////////////////
//keep the session in safe and correct way//
require("inc.php");
//you can put your other php code here //
?>
oxygenws گفت:بابا چرا اینقدر خودخواهید شما.....
اگر جواب رو به دست آوردی، همینجا بنویس تا همه حالشو ببرند.