-1

This is image : http://oi60.tinypic.com/118iq7r.jpg

I have a similar database structure to that shown in the table above. However, I have additional columns for the login times. I would like to take the data from the columns and display them on a page.

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();
?>

This is my profile page.

<?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>';};
                    ?>
Strawberry
  • 33,750
  • 13
  • 40
  • 57
Emre Kozan
  • 11
  • 4
  • 3
    I don't really understand what are you trying to do. Please try to explain yourself better. Otherwise, I can't help you... – barbarity Mar 07 '15 at 09:49
  • Sorry :( I want to show the user's name in the profile page after you log in with the email and password. – Emre Kozan Mar 07 '15 at 09:53
  • First of all as a safety precaution you should never ever store passwords in plain-text, you should always use a [hashing function](http://php.net/manual/en/function.hash.php) to both store and later compare passwords, this makes it so that if an intrusion is found a hacker cannot directly steal the passwords from your database. – Prime Mar 07 '15 at 10:03
  • Thans @AlphaDelta but Priority database can handle it then. Please help? – Emre Kozan Mar 07 '15 at 10:13
  • 1
    I would like to but your English is too broken for me to understand; If I understand you correctly you are asking if a database or server could handle hashing functions, in which case the answer would *yes*. Hashing functions are usually very fast and should always be used to store and compare passwords. – Prime Mar 07 '15 at 10:17
  • @AlphaDelta Sorry bro. All because of the Google Translate. I want to show the table. User Login Page -> Email and Password Section (to be filled) -> User Profile (will be forwarded) -> View user's name to display the page. But I do not know how to check the name. I was able understood correctly. – Emre Kozan Mar 07 '15 at 10:24
  • 1
    Please show us your code and we will try to help you from there. – barbarity Mar 07 '15 at 10:28
  • @barbarity okey man. Created questions. – Emre Kozan Mar 07 '15 at 10:33
  • What error or bad behaviour are you experiencing? – barbarity Mar 07 '15 at 10:37
  • While you are at it, you should start using the PHP mysqli extention or PDO extension instead of mysqli, because the mysql extension is depricated since PHP 5.3. – Lexib0y Mar 07 '15 at 10:38
  • http://oi60.tinypic.com/118iq7r.jpg – Emre Kozan Mar 07 '15 at 10:53
  • @Lexib0y want to draw data from MySQL in a different column that email is located. This column "txtName" a column called.(Yes I know.) – Emre Kozan Mar 07 '15 at 10:57
  • Also, as a safeguard against SQL-Injections, you should not use user-input directly in your SQL. see: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?s=1|22.8949 – MBaas Mar 07 '15 at 11:01
  • My question is never to been resolved :( – Emre Kozan Mar 07 '15 at 11:12
  • http://oi60.tinypic.com/118iq7r.jpg Is there any information on how I can pull data? @barbarity – Emre Kozan Mar 07 '15 at 11:33

2 Answers2

0

You have created the login page. I assume it has no errors. Now, to retrieve data you should do another page profile.php

<?php

session_start();

print_r ($_SESSION);

?>
barbarity
  • 2,420
  • 1
  • 21
  • 29
  • OK buddy status I can not tell for sure? There are two parts as you can see. E-mail and Password sections. Once you've logged in user registration part I want the prior written the name and look of the surname. As I wanted to show in the picture: http://oi60.tinypic.com/118iq7r.jpg – Emre Kozan Mar 07 '15 at 12:26
  • If you want to show the name and surname, you MUST store them in `$_SESSION` array. To do so, you should do it in `login.php` , when you store all others. – barbarity Mar 07 '15 at 16:53
  • I did not need. I solved other problems like myself again.(MYSQL_ARRAY_FETCH) – Emre Kozan Mar 08 '15 at 10:06
  • That not makes sense... Could you publish your solution? – barbarity Mar 08 '15 at 10:09
  • You can solve this problem with the answer I wrote. Thanks for trying, but I solved it myself as other problems. – Emre Kozan Mar 08 '15 at 15:47
0

Despite the people who question the negative points I give the solution to the problem. You can do it this way:

$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');}
}
Prime
  • 2,410
  • 1
  • 20
  • 35
Emre Kozan
  • 11
  • 4