954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

sql approved and banned users

I want to make option to approve users before they can login or to ban them, here is code

<HTML><HEAD><TITLE>Fakultet informacionih tehnologija</TITLE> </HEAD>

<BODY TEXT="#ffffff" BACKGROUND="fakultet/Assets/bg.jpg" LINK="#FFFF00" VLINK="#CDCD00" BGCOLOR="#000000">



<CENTER><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="700">





<CENTER>

  <FONT SIZE=+4 FACE="arial,helvetica">

    Fakultet informacionih tehnologija

   
    <HR>

</CENTER>

<?php
session_start();
// dBase file
include "dbConfig.php";
 
if ($_GET["op"] == "login")
 {
 if (!$_POST["username"] || !$_POST["password"])
  {
	header("Refresh: 3;login.php");
  die("You need to provide a username and password.");
	}


	
 // Create query
 $q = "SELECT * FROM `dbUsers` "
  ."WHERE `username`='".$_POST["username"]."' "
  ."AND `password`=PASSWORD('".$_POST["password"]."') "
  ."LIMIT 1";

 // Run query
 $r = mysql_query($q);
 
 
 if ( $obj = @mysql_fetch_object($r) )
  {
  // Login good, create session variables
  $_SESSION["valid_id"] = $obj->id;
  $_SESSION["valid_user"] = $_POST["username"];
  $_SESSION["valid_time"] = time();
  
  // Redirect to member page
  Header("Location: index.php");
  }
 else
  {
// Login not successful
header('Refresh: 3;login.php');
die("Sorry, could not log you in. Wrong login information.");

	}
	}
else
 {
//If all went right the Web form appears and users can log in
 echo "<form action=\"?op=login\" method=\"POST\">";
 echo "Username: <input name=\"username\" size=\"15\">";
 echo "Password: <input type=\"password\" name=\"password\" size=\"16\">";
 echo "<input type=\"submit\" value=\"Login\">";
 echo "<a href=\"register.php\">Register</a>";
 echo "</form>";
 }
?>

<FONT SIZE=+3>Coded by Filip ^_^</A></FONT>

</BODY></HTML>


and in sql dbusers I have tabs id,user,password,email,approved and banned. So what code I need to add into php to make check for approved/banned?

Thanks in advance

filipgothic
Junior Poster in Training
58 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 
filipgothic
Junior Poster in Training
58 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

no one knows code like if approved =0 die or something?

filipgothic
Junior Poster in Training
58 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

in your Database make another column called approved and make it a tinyint and the default would be 0.

If you want to check if they are approved/banned you add "WHERE approved = '1'" to see if they are active or not.

The tinyint is a boolean so 1 = yes , 0 = no.

Hope that helped

LOVE_outofLIGHT
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You