3 Replies - 1467 Views - Last Post: 14 May 2013 - 04:07 PM

#1 JavaHelper  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 8
  • Joined: 13-May 13

Admin page

Posted 14 May 2013 - 12:30 PM

hi everyone...
my admin page does not work propably when i run it ...
can you help me to find the problem...
<!DOCTYPE html>
<html>
<head>
<title> ADMINISTRATION </title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body background=b.jpg>

<center><img src="a1.jpg"alt="cover"width="1000"height="200"></center>
<hr>
<br>
<center>
<a href="index.php">
<img src="home.jpg"width="100"height="50">
</a>
 <a href="reg.php">
<img src="reg.jpg"width="100"height="50">
</a>
<a href="login.php">
<img src="log.jpg"width="100"height="50">
</a>
<a href="admin.php">
<img src="ad.jpg"width="100"height="50">
</a>
<a href="contact.php">
<img src="us.jpg"width="100"height="50">

</a>


</center>



<html>
<head>
z<title>UsersDetails</title>

</head>

<body>

<?php
session_start();

if(isset($_SESSION['user'])){

if(isset($_SESSION['admin'])){
$conn=  mysql_connect('localhost','root');
mysql_select_db("database",$conn);

if(isset($_POST['Submit'])){
if($_POST['Submit'] == 'Block'){
$sql="UPDATE users SET block='1' WHERE id='$_POST[id]'";
}else{
$sql="UPDATE users SET block='0' WHERE id='$_POST[id]'";
}
if($_POST['Submit'] == 'Admin'){
$sql="UPDATE users SET admin='1' WHERE id='$_POST[id]'";
}else{
$sql="UPDATE users SET admin='0' WHERE id='$_POST[id]'";
}
if($_POST['Submit'] == 'Delete'){
$sql="delete from users  where id='$_POST[id]'";
}
if($result=mysql_query($sql,$conn))
echo "The details are changed<br><a href='admin.php'>back</a>";

else
echo "error";
echo "<br>";

}else{
$sql="select * from users";
$result=mysql_query($sql,$conn);
echo '<table border="3">';
echo '<br><br><tr><th>Name</th><th>Email</th><th>Block</th><th>Admin</th><th>Delete</th>';
while($data = mysql_fetch_array($result)){
echo "<tr><td>$data[name]</td>";
echo "<td>$data[email]</td>";
echo "<td><form action='admin.php' method='post'><input type='hidden' name='id' value='$data[id]'/>";
if($data['block'] ==0)
echo "<input type='submit' name='Submit' value='Block'/></td></form>";
else
echo "<input type='submit' name='Submit' value='Unblock'/></td></form>";
echo "<td><form action='admin.php' method='post'><input type='hidden' name='id' value='$data[id]'/>";
if($data['admin'] ==0)
echo "<input type='submit' name='Submit' value='Admin'/></td></form>";
else
echo "<input type='submit' name='Submit' value='Not Admin'/></td></form>";
echo "<td><form action='admin.php' method='post'><input type='hidden' name='id' value='$data[id]'/>";
echo "<input type='submit' name='Submit' value='Delete'/></td></form>";
echo"</tr>";
}
}
echo '</table>';

}else{
echo 'not allowed';
}}else{
echo 'not login';
}

?>









 

       
</body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: Admin page

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8890
  • View blog
  • Posts: 33,338
  • Joined: 12-June 08

Re: Admin page

Posted 14 May 2013 - 12:33 PM

Quote

my admin page does not work propably when i run it ...

Doesn't work *HOW*?! Is there an exception? If so what is the exception text, and what line is it on? Is the page not functioning as expected? If so what is it doing and what *should* it be doing? Remember - we are not there looking over your shoulder. The more information you can tell us (versus us trying to pry it out of you) the better we are able to help you. Help us to help you sort of thing.
Was This Post Helpful? 0
  • +
  • -

#3 JavaHelper  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 8
  • Joined: 13-May 13

Re: Admin page

Posted 14 May 2013 - 01:10 PM

I'm sorry for that,,
the page show the codes that i wrote ..
but it should be showen a table that help the admin to add or delet users..

this code is what i get when the page runs:

back"; else echo "error"; echo "
"; }else{ $sql="select * from users"; $result=mysql_query($sql,$conn); echo '
'; echo '

'; while($data = mysql_fetch_array($result)){ echo "
"; echo "
"; echo "
"; else echo ""; echo "
"; else echo ""; echo "
"; echo"
"; } } echo 'Name	Email	Block	Admin	Delete
$data[name]	$data[email]	"; if($data['block'] ==0) echo "	"; if($data['admin'] ==0) echo "	"; echo "

'; }else{ echo 'not allowed'; }}else{ echo 'not login'; } ?>


insted of the table
Was This Post Helpful? 0
  • +
  • -

#4 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1357
  • View blog
  • Posts: 3,424
  • Joined: 28-November 09

Re: Admin page

Posted 14 May 2013 - 04:07 PM

...is PHP even installed and configured on your server? If so, then you missed a quote somewhere in there.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1