|
lagi 1 kan...based on login id tu...cane kite nak paparkan semua data dlm DB?....kalo yg td just papar username yg login... |
|
|
|
|
|
|
|
nak unset just letak $_SESSION['username'] = ''; atau session_unset();
nak display semau data user yg login
$sql = "SELECT * FROM table WHERE username = '". $_SESSION['username'] ."'"; |
|
|
|
|
|
|
|
bile dah panggil $sql = "SELECT * FROM table WHERE username = '". $_SESSION['username'] ."'"; [/quote]..
cane nak display data dlm table tu?...
ni coding utk check login
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="1234"; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// encrypt password
$encrypted_mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);
// 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);
// 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 "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
?>
<script language=javascript>
window.alert (" Wrong Username n Password. Please Login Again");
</script>
<?
echo "<meta http-equiv=\"refresh\" content=\"1;url=main_login.php\">\n";
}
?>
yg ni lak login success...yg kat sini aku dpt papaerkan username n password je...nak paparkan nama penuh cane?
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<html>
<body>
<p>Welcome <? echo $_SESSION['myusername']; ?> </p>
<p> <? echo $_SESSION['mypassword']; ?></p>
<p> </p>
<p><a href="main_login.php">logout </a></p>
<? session_unset();
?>
</body>
</html> |
|
|
|
|
|
|
|
ok2...dah dpt paparkan semua data....thanksss |
|
|
|
|
|
|
|
cane ek nak clear semua data lepas logout?? |
|
|
|
|
|
|
|
data apa yg ko nak clearkan????
kalau session --> session_unset(); |
|
|
|
|
|
|
|
mcm kan bila aku 1st login tu aku panggil semua data dlm DB masuk ke sistem...pastu bile aku masuk pakai id lain..maklumat same gak kuar...nape ye... |
|
|
|
|
|
|
|
selalu lepas query aku buat free result
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result)
{
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_assoc($result);
dan setiap page buat close conecction
mysql_close($link); |
|
|
|
|
|
|
|
ooo..thanks..nanti aku cube... |
|
|
|
|
|
|
|
saper tau nak setting date dlm malay?..yg dlm tenet aku jumpe english je.. |
|
|
|
|
|
|
|
Originally posted by pzan213 at 24-12-2008 09:17 PM
saper tau nak setting date dlm malay?..yg dlm tenet aku jumpe english je..
guna array() |
|
|
|
|
|
|
|
boardmanager..tau xpasal ape nie?..aku wat coding utk forgotten password...tp time run dier kuar niee
Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in C:\xampp\htdocs\xampp\test\send_password_ac.php on line 52
Cannot send password to your e-mail address |
|
|
|
|
|
|
|
1. check ko punya smtp server ok ke tak.......
2. check setting kat php.ini letak smtp server = localhost , port =25 |
|
|
|
|
|
|
|
guna telnet
The output on my system looks like this:
root@server1# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 server1.example.com ESMTP Postfix (Ubuntu)
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host. |
|
|
|
|
|
|
|
Originally posted by BorderManager at 26-12-2008 11:19 PM
guna telnet
The output on my system looks like this:
root@server1# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 server1.exam ...
pening dahhh...hehehe |
|
|
|
|
|
|
|
lagi 1 nak tny la...sini ade paparan...lepas tu kan cane kite nak wat link kat paparan tu ye...yg aku paparkan nie xde link...aku nak bile je kite pnggil dr DB...dier akan appar..pastu ader link pada nama or nokp tu..n then bile klik je link tu..dier p page yg ader full detail....
|
|
|
|
|
|
|
|
aku tak tau pasal smpt window.. selalu guna postfix & sendmail je
ko buat je mcm n....
- <a hef="details.php?id=<?= $row['id'] ?>"><?= $row['name'] ?></a>
Copy the Code
kat details.php tu
- $sql = "SELECT * FROM user WHERE id = ". $_GET['id'];
Copy the Code |
|
|
|
|
|
|
| |
|