ordebehesht
Member
دوستان سلام این کد مشکلش چیه هنگام اجرا می گه نمیتونه کوئری رو اجرا کنه
اینم دیتا بیس
کد:
<?php
@$name=$_POST['name'];
@$password=$_POST['password'];
if(!isset($name)&& !isset($password))
{
?>
<h1>Please Log In</h1>
this page is secret.
<form method="post" action="Secretdb.php">
<table border="1" align="center">
<tr>
<td>Username</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Log In"></td>
</tr>
</table>
</form>
<?php
}
else
{
$mysql=mysqli_connect('localhost','root','',auth);
if(!$mysql)
{
echo 'cannot connect to datebase';
exit;
}
$selected=mysqli_select_db($mysql,'auth');
if(!$selected)
{
echo 'cannot select datebase.';
exit;
}
$query="select count (*) from authorized_users where name='$name' password='$password'";
$result=mysqli_query($mysql,$query);
if(!$result)
{
echo 'cannot run query.';
exit;
}
$row=mysqli_fetch_row($result);
$count=$row[0];
if($count>0)
{
echo('<h1>Here it is!</h1>');
echo 'I bet you are glad you can see this secret page.';
}
else
{
echo('<h1>Go Away!</h1>');
echo 'you are not authorized to view this resource.';
}
}
?>
کد:
create database auth;
use auth;
create table authorized_users(name varchar(20) , password varchar (40),primary key(name));
insert into authorized_users('user name', 'password');
آخرین ویرایش: