0

ちょっと私はここにいるのは初めてです。誰もがphpとmysqlのこのコードの塊で私を助けることができます。これは小さな間違いであることは知っていますが、エラーがどこにあるのかわかりませんでした。これはコードです:

//index.php

<html>
<head>
<title>Search for a user</title>
</head>
<body>
<h2> Search for a user below:</h2><br /><br />
<form action="profileprocess.php" method="get">
  <table>
   <tr>
    <td>Username:</td><td><input type="text" id="username" name="username" /></td></tr>
    <tr>
    <td><input type="submit" name="submit" id="submit"  value="View Profile" /></td>
    </tr>


  </table>


</form>
</body>
</html>

// profileprocess.php

<html>
<head>
<title><?php echo $username; ?> <?php echo $lastname; ?>s profile</title>

</head>
<body>
<?php
 if(isset($_GET['username'])){

    $username = $_GET['username']; 
    mysql_connect("localhost", "root", "") or die ("could not connect t the server");
    mysql_select_db("users") or die("this database was not found");
    $userquery = mysql_query("SELECT * FROM users WHERE username='$username'") or die("the query could be fale please try again");
    if(mysql_num_rows($userquery) != 1){
        die("that username could not be found!");
    }
    while($row = mysql_fetch_array($userquery, MYSQL_ASSOC)){
       $firstname = $row['firstname'];
       $lastname = $row['lastname'];
       $email = $row['email'];
       $dbusername = $row['username'];
       $activated = $row['activated'];
       $access = $row['access'];
       }
       if($username != $dbusername){
         die ("there has been a fatal error please try again. ");
       }
       if($activated == 0){
        $active = "this account has not been activated";
       }else{
          $active = "ths  account has been activated";
       }

       if($access == 0){
         $admin = "this user is not administrator";
       }else{
         $admin = "this user is  an administrator";
       }
?>
<h2><?php echo $username; ?> <?php echo $lastname; ?>s profile</h2>
<table>
<tr>
<td>firstname:</td><td><?php echo $firstname; ?></td>
</tr>
<tr>
<td>lastname:</td><td><?php echo $lastname; ?></td>
</tr>
<tr>
<td>email:</td><td><?php echo $email; ?></td>
</tr>
<tr>
<td>username:</td><td><?php echo $dbusername; ?></td>
</tr>
<tr>
<td>activated:</td><td><?php echo $active; ?></td>
</tr>
<tr>
<td>access:</td><td><?php echo $admin; ?></td>
</tr>

</table>


<?php      
 }else die("You need  to specify a username!");


?>

</body>
</html>

////何か助けて????

4

2 に答える 2

2

このコードを XAMPP サーバーで実行したところ、問題なく動作しているようです。

<html>
<head>
<title>Search for a user</title>
</head>
<body>
<h2> Search for a user below:</h2><br /><br />
<form action="" method="get">
  <table>
   <tr>
    <td>Username:</td><td><input type="text" id="username" name="username" /></td></tr>
    <tr>
    <td><input type="submit" name="submit" id="submit"  value="View Profile" /></td>
    </tr>


  </table>


</form>
</body>
</html>

<?php
 if($_GET['username'] != ''){
     echo $_GET['username'];

 } else 
 die('doesnt work'); ?>
于 2013-02-08T10:19:40.863 に答える
0

私が間違いなく見ている問題の 1 つは、ページの開始時に echo を使用していて、クエリが実行されていないことです。それはエラーをスローします。

また、エラーの内容をお知らせください。より適切なサポートを提供できるようにいたします。

于 2013-02-08T09:51:56.453 に答える