이 코드는 여기에서 완벽하게 잘 작동합니다. 내가하고 싶은 것은 $ userName에 이미 저장되어있는 FirstName과 LastName (SESSION 사용)을 전달하는 것이다. 이름과 성은 실제로 로그인 할 때 데이터베이스에서 검색됩니다. 나는 모든 페이지에 이름과 성 쇼가 한 번에 기록하고 싶지 ... 감사합니다세션 변수가 다음 페이지로 동적으로 전달됨
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><?php
$DisplayForm = TRUE;
$errors = 0;
if(isset($_POST['uname']) && isset($_POST['pass'])) {
include("dbconnect.php");
if($DBConnect !== FALSE){
$SQLstring = "SELECT userid, first_name, last_name FROM users WHERE username ='".
$_POST['uname']. "' and password = '".md5($_POST['pass'])."'";
$DisplayForm = FALSE;
$QueryResult = @mysql_query($SQLstring, $DBConnect);
echo mysql_error();
if (mysql_num_rows($QueryResult)=== 0){
echo "<p style='color:red;'><b> The email address/password " .
" combination is not valid.</b></p>\n";
++$errors;
$DisplayForm = TRUE;
}
else
{
$DisplayForm = FALSE;
}
}
}
if ($DisplayForm)
{?>
<form id="form1" name="loginForm" method="post" action="index.php">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="93" bgcolor="#DACFAF"><strong> Username:</strong></td>
<td width="149" bgcolor="#DACFAF"><label for="textfield"></label>
<input type="text" name="uname" id="textfield" /></td>
<td width="76" bgcolor="#DACFAF"><strong>Password:</strong></td>
<td width="150" bgcolor="#DACFAF"><label for="textfield2"></label>
<input type="password" name="pass" id="pass" /></td>
<td width="196" bgcolor="#DACFAF"><input type="image" name="login" src="images/login.jpg" /> </td>
<td width="68" bgcolor="#DACFAF"> </td>
<td width="68" bgcolor="#DACFAF"><strong><a href="register.php">Register</a> </strong> </td>
</tr>
</table>
</form>
<?php }
else {
$Row = mysql_fetch_assoc($QueryResult);
$userID = $Row['userid'];
$userName = $Row['first_name']. " ". $Row['last_name'];
echo "<table width=780px border=0px >";
echo "<tr>";
echo "<td style='color:red;'>";
echo "<b> Welcome back, $userName!</b>";
echo "</td>";
echo"<td align='right'>";
echo "<form method='POST' action=''>";
echo "<input type='submit' name='submit' value='logout'>";
echo "</form>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
?> </td>
</tr>
</table>
_ 정확히 당신의 문제는 무엇입니까? _ –
지금 어떤 결과가 나타 납니까? –
세션을 실제로 전달하는 방법을 잘 모르겠습니다. 나는 폼들간에 전달할 수 있지만 다이나믹은 실제로 작동하지 않습니다. – user3479738