Jump to content


Mr-Chidi

Member Since 20 May 2008
Offline Last Active Feb 27 2015 08:58 AM

Topics I've Started

Add Admin Access to All Accounts

26 February 2015 - 10:52 AM

Hi all,

 

I am wondering how to get this to work or if it is possible. I have an application that was not built with the admin having access to all the users account but now i want it to have access to all accounts.

 

Thanks. (though i've not tried anything yet, just dont know how to start and i dont want to start afresh: advice)

 

My current login code is:

 

<?php
    
if(isset($_POST['login'])){

$username = stripslashes($_POST['username']);
$password = stripslashes($_POST['password']);


$stmt = $pdo->prepare("SELECT password FROM tablename 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">&times;</span></button>INVALID USERNAME OR PASSWORD</div></p>';

}else{

list($hash) = $stmt->fetch(PDO::FETCH_NUM);

if (password_verify($password, $hash)) {
//$_SESSION['username'] = $username;

$status1 = "COMPLETED";
$status2 = "PROCESSING";

//$stmt = $pdo->query("SELECT status FROM ca_confirmed WHERE username ='$_SESSION[username]'");
$stmt = $pdo->query("SELECT status FROM tablename WHERE username ='$username'");
$check = $stmt->fetch(PDO::FETCH_ASSOC);
$status = $check['status'];

$_SESSION['username'] = $username;
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">&times;</span></button>INVALID USERNAME OR PASSWORD again</div></p>';

}    
}
}
?>  

login into two different areas on one login form

20 February 2015 - 10:52 PM

Hi all.

I'm trying to get user login into two different areas on one login form based on a criteria. The problem I'm having is that if the correct passwords are provided, everything works fine but when a wrong password is provided, nothing happens, it doesn't even echo the password error alert! What could be wrong and is my code okay?

Thanks

if(isset($_POST['login'])){

$username=$_POST['username'];
$password=$_POST['password'];

$username = stripslashes($username);
$password = stripslashes($password);
$username = $username;
$password = $password;

//$pass = md5($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">&times;</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">&times;</span></button>INVALID USERNAME OR PASSWORD again</div></p>';

}    
}
}
}

 

Fatal error: Class 'PDO' not found

31 January 2015 - 09:31 AM

Hi all.

 

Just seeing this error now.

funny enough the site have been live for about a week only to bring this error now!

 

Fatal error: Class 'PDO' not found in /home/mysite/public_html/includes/file.php on line 21

 

and this is the file.php

$database='mydb';
$user='username';
$password='password';
$dsn="mysql:host=localhost;dbname=$database";

try {
$pdo = new PDO($dsn,$user,$password); // mysql
} catch(PDOException $e) {
die ('Failed to connect'); // Exit, displaying an error message
}

i just saw this today and it's on godaddy

 

thanks


notification badge in php

30 January 2015 - 02:15 PM

hi all,

how can i create a notification badge in php eg like when i have a new message, it will display on the nav indicating new message and the number of messages.

thanks


Reward Logic

06 January 2015 - 04:10 AM

I have a referal system. I want to have a reward for referring someone. I allocate a certain amount for the referal system (lets say $50). At level 1, nothing is given until you start referring people and the person(s) starts using the program.

On level 2 you earn 9%($4.5 of $50)
on level 3 you earn 27%
On level 4 you earn 64%


How do i go about this bearing in mind that a level 2 or 3, eventually becomes level 1 if he starts inviting people and those he invited starts using the program.


Thanks
 


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

AlphaBit.com