我的代码以这种方式工作。我有一个登录,当管理员登录时,他可以输入名称并提交。应向用户显示与该名称对应的所有数据库值。现在我得到的是,管理员可以输入值(名称)并点击提交。循环不显示 values ,而是存在并转到另一个函数。我哪里错了?
if( $_SESSION["logging"]&& $_SESSION["logged"])
{
print_secure_content();
}
function chk()
{
if($res[ROLE]=='admin')
{
echo "hey admin";
<form action="" method=post>
<input type = "text" name="submit" />Enter<br/>
<input type="submit" name="submit" value="submit"/>
<?php
//It never gets inside this loop and directly jumps to print() function
if(isset($_POST['submit']))
{
echo "helloooo";
$sq="select `name` from users where NAME='$_POST[submit]'";
$result1=mysql_query($sq,$con) or die(mysql_error());
while($res1=mysql_fetch_assoc($result1));
{
echo "hiiiii";
$user['name']=$res1['NAME'];
echo $user['name'];
} ?>
<input type="text" name="fo" class="textfield" value="<?php echo $user['name']; ?>"/>
</label><br />
<?php
return mysql_num_rows($user);
}
}
// this gets executed
function print_secure_content()
{
print("<b><h1>hi $_SESSION[user]</h1>");
print "<br><h2>only a logged in user can see this</h2><br><a href='logout.php'>Logout</a>
}