Jump to content


Mr-Chidi

Member Since 20 May 2008
Offline Last Active Apr 23 2015 06:59 AM

Posts I've Made

In Topic: What could be wrong

14 March 2015 - 04:03 PM

something tells me that the rows between these two tables (using table names like table1, table2 doesn't provide useful context) are not related to each other using any sort of foreign key, but are two different types of data (that perhaps should all be in one table) that the OP wants to retrieve with the data for each username (which should actually be a userid) together in the result set. if so, you need to use a UNION query.

yeah. u are right. the only relationship with both tables is the username. a table may have more info on it than the other.

 

thanks


In Topic: Add Admin Access to All Accounts

27 February 2015 - 02:30 AM

It can be done. The site will be role based. Admin from his dashboard can control everything. You need to create a proper database table structure for doing this.


how can it b done with my login code? that's d issue

In Topic: Add Admin Access to All Accounts

26 February 2015 - 10:25 PM

While I don't fully understand what your code is doing, I do not see anything regarding your initial question. In what way are you currently controlling who accesses what with this code?

 

The code is my login page. currently only the user is able to login from there, but was wondering if i could modify it so that an admin can login into any of the account with a master password


In Topic: login into two different areas on one login form

21 February 2015 - 02:43 PM

 


This is because this else is in the wrong place.

else{    echo '<div class="signals"><p class="bg-warning text-center warning"><button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>INVALID USERNAME OR PASSWORD again</div></p>';}
You have have after the if/elseif strcmp statements. It should be after the  if (password_verify($password, $hash))  block.
if(isset($_POST['login'])){    $username = stripslashes($_POST['username']);    $password = stripslashes($_POST['password']);    $stmt = $pdo->prepare("SELECT password FROM table WHERE username=:username");    $stmt->bindValue(':username', $username, PDO::PARAM_STR);    $stmt->execute();    if($stmt->rowCount()<1)    {        echo '<div class="signals"><p class="bg-warning text-center warning"><button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>INVALID USERNAME OR PASSWORD</div></p>';    }    else    {        $password = $_POST['password'];        list($hash) = $stmt->fetch(PDO::FETCH_NUM);        if (password_verify($password, $hash))        {            $_SESSION['username'] = $username;            $status1 = "COMPLETED";            $status2 = "UNCOMPLETED";            $stmt = $pdo->query("SELECT status FROM table WHERE username ='$_SESSION[username]'");            $check = $stmt->fetch(PDO::FETCH_ASSOC);            $status = $check['status'];            if(strcmp($status, $status1) == 0)            {                header("location: completed/index.php");                exit();            }            elseif(strcmp($status, $status2) == 0)            {                header("location: uncompleted/index.php");                    exit();            }          }        else        {             echo '<div class="signals"><p class="bg-warning text-center warning"><button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>INVALID USERNAME OR PASSWORD again</div></p>';        }     }}
 

Thanks

In Topic: notification badge in php

03 February 2015 - 04:22 AM

Finally this is what worked for me. I've tested it several times and it worked. mac_gyver was right but in my own case only the admin visits the site and not multiple users.

 

Had to device my own means. Thanks mac_gyver and cronix for the inspiration!!!

 
    $stmt = $pdo->query("SELECT * FROM $tbl_name");
    $stmt->execute();
    $num_rows = $stmt->rowCount();
    print "<p>$num_rows Record(s) Found.</p>";
 
echo "<table width='100%' border='1' bordercolor='#0cc' cellspacing='0' cellpadding='2'>";
echo "<tr>
    <th bgcolor='#444444' align='center'><font color='#fff'>Surname</font></th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Firstname</font></th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Email / Username</th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Phone</th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Date Registered</th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Status</th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Create Account</th>
    <th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</th>
    </tr>";
// keeps getting the next row until there are no more to get
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {

    $clas = $row['entry'];
    if($clas == 'NEW'){
        $style = " style='font-weight:bold'";
    }else{
    $style = " style='font-weight:normal'";    
    }
  
    // Print out the contents of each row into a table
    echo "<tr{$style}><td>";
    echo ucfirst($row['surname']);
    echo "</td><td>";
    echo ucfirst($row['firstname']);
    echo "</td><td>";
    echo $row['email'];
    echo "</td><td>";
    echo $row['phone'];
    echo "</td><td>";
    echo $row['today'];
    echo "</td><td>";
    echo $row['status'];
    echo "</td><td>";
    echo "<a href='create-account.php?id={$row['id']}'>Create Account</a>";
    echo "</td><td>";
    echo "<a href='account-delete.php?id={$row['email']}'>Delete Account</a>";
    echo "</td></tr>";
}
echo "</table>";

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com