Jump to content

How to retrive this sql on PHP


xxreenaxx1

Recommended Posts

You should show the code you are having difficulties with. But simplified usage of database in PHP:

<?php

// Connect to MySQL using PHP Data Objects
$pdo = new PDO('mysql:host=your_host_here;dbname=database_name', 'username', 'password');

// For this test you want to see any errors occure without having to get them yourself
$pdo->setAttribute(PDO::ERRMODE_WARNING, TRUE);

$stm = $pdo->prepare('SELECT * FROM user WHERE Rol_ID = 1');
$stm->execute();

$result = $stm->fetchAll();

print_r($result);

?>

Sorry.

 

I did that it wont work. It let everyone in. As in even if the Rol_ID was 2

 

<?PHP
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("Examination") or die(mysql_error());

if ($_POST['submit'])
{
//get data
$username= $_POST['user'];
$password =$_POST['pass'];

	if ($username && $password)
	{

	$query = mysql_query("SELECT * FROM user WHERE Rol_ID =1");
	while($getrows =mysql_fetch_assoc($query))
	{
		$dbuser = $getrows['user'];
		$dbpass = $getrows['pass'];

	}

		if (($username == $dbuser)  &&($password == $dbpass))
	{
		header("location:login_success.php");

	}

		else
		{
			echo"failed";
		}
	}
	else
	{
		die("Field not empty");
	}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.