MySQL如何从行中相同的不同列查询数据


MySQL How data is queried from the same different columns in the row?

这是图像:http://oi60.tinypic.com/118iq7r.jpg

我有一个与上表中所示类似的数据库结构。不过,我还有其他关于登录时间的列。我想从列中获取数据并将其显示在页面上。

ID | txtName | txtEmail        | txtPasswd
-------------------------------------------
1  | Ahmet   | ahmet@gmail.com | 123123
2  | Ali     | ali@gmail.com   | 312 321

<?php 
session_start();
ob_start();
include 'connect.php';
$email = $_POST['txtEmail'];
$password = $_POST['txtPasswd'];
$cryptpass = md5($password);
$login = mysql_query("select * from users where txtEmail='".$email."' and txtPasswd='".$cryptpass."' ") or die(mysql_error());
if(mysql_num_rows($login))  {
    $_SESSION["login"] = true;
    $_SESSION["user"] = $password;
    $_SESSION["pass"] = $password;
    $_SESSION["email"] = $emailadress;
    header("location:index.php");
}
else
{
    if($email=="" or $password=="") {
        echo "";
    } else {
        header('Location:index.php?error=1');
        exit;
    }
}
ob_end_flush();
?>

这是我的个人资料页面。

<?php
if (empty($_SESSION["fullname"])) {
    $fullnamequery = "";
}



                    if(!empty($_SESSION['login'])) {
                                           echo '<li class="user logged">
                                            <a href="http://www.petkod.com/hesabim/bilgilerim" title="'.$_SESSION['fullname'].'">'.$_SESSION['fullname'].'<span class="arrow"></span></a>
                                            <div class="subMenu">
                                                <ul>
                                                    <li><a href="http://www.petkod.com/hesabim/bilgilerim" class="info">Bilgilerim</a></li>
                                                    <li><a href="http://www.petkod.com/hesabim/petlerim" class="pet">Petlerim</a></li>
                                                    <li><a href="http://www.petkod.com/hesabim/adreslerim" class="address">Adreslerim</a></li>
                                                    <li><a href="http://www.petkod.com/hesabim/siparisler" class="order">Siparişlerim</a></li>
                                                    <li><a href="logout.php" class="logout">Çıkış</a></li>
                                                </ul>
                                            </div>
                                        </li>'; 
}else{echo '<li class="user"><a href="popup-login.php" data-width="520" data-height="556" class="iframe">Giriş Yap</a></li>';};
                    ?>

您已经创建了登录页面。我认为它没有错误。现在,要检索数据,您应该执行另一个页面profile.php

<?php
session_start();
print_r ($_SESSION);
?>

尽管有人质疑负面观点,我还是给出了问题的解决方案。你可以这样做:

$userquery = mysql_query("select * from users where txtEmail='".$email."' and txtPasswd='".$cryptpass."' ");
if(mysql_num_rows($userquery)>0)
{
    header('Location:index.php?error=2');
    exit;
} else {
    $register = "INSERT INTO users (txtName,txtEmail,txtPasswd,txtGsm) VALUES ('$fullname','$email','$cryptpass','$gsm')"; 
    mysql_query("$register") or die(mysql_error()); 
    $_SESSION['login'] = true;
    $_SESSION['fullname'] = $fullname;
    $_SESSION["email"] = $email;
    $_SESSION["gsm"] = $gsm;
    header('location:index.php');}
}