1

Ok, look im off to bed now but il have a look at this first thing in the morning. Im sure I can pass on the working system by tomorow 12pm :D

Get some sleep and thanks for posting

Votes + Comments
he helped me alot
0

Hey

I decided to have a go before going to sleep :D

All is working nicely and i've added a few peices of my own.
There are still a few problems with your forum but there small and you should have a go at finding whats gone wrong.

Im posting the new pages bellow. Have a look through and be sure to read the comments on the connection.php. Its quite important.

I beleive the login script which is the reason for you posting this is working absolutely fine, and is updating correctly.
If you have any more problems dont hesitate to mail me on here. I have the code on my computer so I can help straight away.

Also, if you have trouble with the forum just drop me a note.

Hope all this helps

Have I helped? Add to my repluation :)

Attachments
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
  <title></title>
</head>

<body>

<?php
$sub=$_REQUEST['sub'];
$desc=$_REQUEST['desc'];



if (isset($_POST['user'])) {
 $uid = $_POST['un'];
} else {
 $user = $_SESSION['user'];
}

$sql="insert into topics (subject,author,description,tdate) values ('$sub','$user','$desc','2-2-2002'))";
$res=@mysql_query($sql)
 or die("Unable to execute query");

$insertid=mysql_insert_id();



	header("Location: http://www.forum.com/detailtopic.php?idt=$insertid");



?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
  <title></title>
</head>

<body>

<?php
$user=$_SESSION['user'];
$idt=$_REQUEST['idt'];
$title=$_REQUEST['title'];
$msg=$_REQUEST['msg'];
$dbh=@mysql_connect('localhost','root','')
or die ('Cannot Connect');



$sql="insert into comments (title,message,author,topicid) values ('$title','$msg','$user','$idt')";
$res=mysql_query($sql)
     or die('<p>Error creating joke table: ' .
     mysql_error() . '</p>');

  header("Location: http://www.forum.com/detailtopic.php?idt=$idt");

?>

</body>

</html>
<?php

/* By having this all on the one page it is easier to edit your connection details without
having to go through all your other pages. Also this file should actually be places outside your public_html on your server otherwise
people have access to your mysql and all the users data is readable. Ask me if you have any problems
 */
 
$host = "localhost";
$user = "root";
$pass = "";
if (mysql_connect($host, $user, $pass)) {
// echo "Connection Made";
mysql_select_db ("daniweb")
or die ("Could not select database");
}
else {
echo "Couldnt Connect";
}            

?>
<?php

    session_start();
include "connect.php";

   ?><html>

<head>
  <title></title>
</head>

<body>

<?php
  $id=$_REQUEST['topics'];


           //$query="delete  from topics where id='$todelete'";

           $query ="DELETE  FROM users WHERE id =$id";
           print $query;
    $result = mysql_query($query)
               or die ('Query Failed');


           echo 'Topic Deleted Succesfully';
          //echo '<meta http-equiv="Refresh" content="2; url=http://www.forum.com/home1.php" />';


?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
  <title></title>
</head>

<body bgcolor=grey>

<?php
$idt=$_REQUEST['idt'];
$user=$_SESSION['user'];

$result=@mysql_query('select * from topics');
if(!$result){
exit('no data found');
}



 while ($row = mysql_fetch_array($result)) {
  if($row['id']== $idt){
  	$u=$row['author'];
     $sql="select count(*) from topics where author='$u'";
      $res=@mysql_query($sql);

   if(!$res){
    exit('no data found1');
    }
         echo ' <b><a href=index.php>Abdullah Forum</a> > <a href=home.php>Home</a> > <a href=detailtopic.php>'.$row['subject'].'</a><b><br><br>';
     	echo '<b>Subject :'.$row['subject']."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author: ".$row['author']."
     	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Posts :".$res."<br>";
     	echo  'Description</b> :<br><br>'.$row['description'];
     	echo '<hr>';



    }

 }


  $query = "SELECT * FROM comments";
  $result = mysql_query ($query)
    or die ("Query failed");

 while ($row = mysql_fetch_array($result)) {
    if($row['topicid'] == $idt){
    	$title=$row['title'];
    	$author=$row['author'];
    	$msg=$row['message'];
   print "<b>Title : $title &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author :$author</b> <br> $msg <hr>";

   }
}

print "<a href=new_reply.php?idt=$idt>Reply To Thread</a>";


?>

</body>

</html>
<?php

session_start();
include "connect.php";

?>
<html>
<b><a href="index.php">Abdullah's Forum</a> > <a href="home.php">Home</a> </b><br>
      <meta http-equiv="Refresh" content="300; url=http://www.forum.com/logout.php" />
<head>
  <title></title>
</head>

<body>

<?php

$p = $_SESSION['pass'];
$query = "UPDATE users SET loggedin=1 WHERE  pass='$p' ";
mysql_query ($query) or die ("Query failed");

$username=$_SESSION['user'];

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

print "<table width=100% height=10% border=1 bordercolor=black>
<tr><td>Welcome &nbsp;&nbsp;&nbsp;&nbsp; $username</td>
<td><a href=logout.php>Logout</a></td></tr></table> ";
echo "<br><br>";



$query = "SELECT * FROM topics";
       $result = mysql_query ($query)
         or die ("Query failed");

       while ($row = mysql_fetch_array($result)) {
       echo '<a href="detailtopic.php?idt=';
       echo  $row['id'];
       echo  '">'.$row['subject'].'</a><br><hr>';
       }
       echo '<a href="newtopic.php">Add New Topic</a>';


   $query1= "SELECT * FROM users";
       $res = mysql_query ($query1)
         or die ("Query failed");
          while ($r = mysql_fetch_array($res)) {
          echo $r['loggedin'];
          }

       }
  else{
       	header("Location: http://www.forum.com/logout.php");
  }

?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>
      <meta http-equiv="Refresh" content="300; url=http://www.forum.com/logout.php" />
<head>
  <title></title>
</head>

<body>

<?php



$username=$_SESSION['user'];

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

print "<table width=100% height=10% border=1 bordercolor=black>
<tr><td>Welcome &nbsp;&nbsp;&nbsp;&nbsp; $username</td>
<td><a href=logout.php>Logout</a></td></tr></table> ";
echo "<br><br>";



$query = "SELECT * FROM topics";
       $result = mysql_query ($query)
         or die ("Query failed");

       while ($row = mysql_fetch_array($result)) {
       print "<form action='delete.php' method='post'>";
       print '<input type="checkbox" name="topics" value=';
       echo   $row['id'];
       echo     '">';
       print '<a href="detailtopic.php?idt=';
       echo  $row['id'];
       echo  '">'.$row['subject'].'</a>';
       print '&nbsp;&nbsp;&nbsp;<a href=update.php?idt=';
       print $row['id'];
       print '>Update Topic</a><br><hr>';

       //print "<a href=www.forum.com/update.php>Update</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=www.forum.com/update.php>delete</a>";
       }
       print "<input type='submit' value='Delete'></form>" ;

       echo '<a href="newtopic.php">Add New Topic</a>';
       print '<br><br><br><br><br><br><a href="admin.php">Control Panel</a>' ;

       }

  else{
       	header("Location: http://www.forum.com/logout.php");
  }

?>

</body>

</html>
<?php 
session_start();
include "connect.php";  //creates a connection with the database
?>
<html>
<head>
<title>Welcome</title>

<?php 

if (!isset ($_SESSION['loggedin']) || $_SESSION['loggedin'] != true) { ?>
  <h2>Welcome Guest</h2>
  <body bgcolor=grey >

  <b>You must login or become a user</b><br><br>
<form name="login" method="post" action="login1.php">
Username: <input type="text" name="un"><br>
Password:<input type="password" name="pass"><br>
Remember Me: <input type="checkbox" name="rememberme" value="1"><br>
<input type="submit" name="submit" value="Login!">
</form>

<a href="signup.php">Signup</a> <br><br><br>

<?php
} else {
?>
  <h2>Welcome <?php echo $_SESSION['name']; ?></h2>
  <body bgcolor=grey >

  <b>You are logged in</b><br><a href="logout.php">Logout</a><br><br><h3><a href="home.php">Home</a><br><br>
<?php
$pass = $_SESSION['pass'];
$query = "UPDATE users
SET loggedin=1 WHERE pass='$pass'";
mysql_query($query) or die (mysql_error());


$count = "SELECT COUNT(*) FROM topics";
$send = mysql_query($count) or die ("Couldnt count");
$collect = mysql_fetch_array($send); 
if ($collect[0] == 0) {
echo "There are no topics";
}

else {
$query = "SELECT * FROM topics";
$result = mysql_query($query) or die ("Couldnt do query");
while ($row = mysql_fetch_array($result)) {
       echo '<a href="detailtopic.php?idt=';
       echo  $row['id'];
       echo  '">'.$row['subject'].'</a><br><hr>';
}
}
}
?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
<title></title>
</head>

<body>

<?php

$result=mysql_query('select * from users');
if(!$result){
exit('no data found');
}
$t=0;
$u=$_REQUEST['un'];
$p=$_REQUEST['pass'];

$encpass=md5($p);
$_SESSION['pass'] = $encpass;
while($row=mysql_fetch_array($result)){

if(($row['name']== $u) && ($row['pass']==$encpass)){
$t=1;
}
if($u=='admin'){
		if(($row['name']== $u) and ($row['pass']==$encpass)){
		$t=2;
		}
}


}


if($t==1){

$_SESSION['user']=$u;
$_SESSION['pass'] = $encpass;



echo '<meta http-equiv="Refresh" content="2; url=home.php" />';

  print "<center>  Thank you for logging in, $u <br>

Click here if your browser does not automatically redirect you.</center>";





}
if($t==0){
	echo 'Couldnt Log You In';
}

    if($t==2){
	    $_SESSION['user']=$u;
$_SESSION['pass'] = $encpass;


        echo '<meta http-equiv="Refresh" content="2; url=http://www.forum.com/home1.php" />';

         print "<center>  Thank you for logging in, $u <br>

			Click here if your browser does not automatically redirect you.</center>";
          }


?>
</body>
</html>
<?php
session_start();
include "connect.php";
$pass = $_SESSION['pass'];
$query = "UPDATE users
SET loggedin=0 WHERE pass='$pass'";
mysql_query($query) or die ("Couldnt update");
session_destroy();
?>
<html>

<head>
  <title></title>
</head>

<body>

<?php


         echo '<center><meta http-equiv="Refresh" content="2; url=index.php" />';
   echo 'You Have Been Logged out .. You Have To Sign in Again</center>';




?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>
         <meta http-equiv="Refresh" content="300; url=http://www.forum.com/logout.php" />
<head>
  <title></title>
</head>

<body>

<?php
echo $_SESSION['user'];
?>

<form action="addtopic.php" method="post">
Subject :	<input type="text" name="sub"><br>
Description :<textarea name="desc" col="400" row="200"></textarea><br>
<input type="submit" value="Confirm new topic">
</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>
      <meta http-equiv="Refresh" content="300; url=http://www.forum.com/logout.php" />
<head>
  <title></title>
</head>

<body>

<?php
 if(isset($_SESSION['user'])){
$idt=$_REQUEST['idt'];


$sql="SELECT * FROM topics";
$res=@mysql_query($sql)
      or die('Query failed');

      while($row=mysql_fetch_array($res)){
               if($idt ==	$row['id']){
                $topic=$row['subject'];
                }
       }
                  echo ' <b><a href=index.php>Abdullah Forum</a> > <a href=home.php>Home</a> > <a href=detailtopic.php>'.$topic.'</a> > <a href=new_reply.php>Reply to thread</a><b><br><br>';
  print "Reply To Thread &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thread: $topic<br><br>";
  }
     else
                       {
                       	header("Location: http://www.forum.com/logout.php");
                       }

?>
<form action="add_reply.php" method="post">
Title <input type="text" name="title"><br>
<input type="hidden" name="idt" value="<?php echo $idt; ?>">
Message <br><textarea row="800" col="800" name="msg">
</textarea><br>
<input type="submit" value="Submit Reply">
</form>

</body>

</html>
<?php
session_start();
include "connect.php";
?>
<html>
   <meta http-equiv="Refresh" content="300; url=http://www.forum.com/logout.php" />
<head>
  <title></title>
</head>

<body bgcolor="#666666">
<center><h1>Sign Up</h1>

                  <?php

if (isset ($_REQUEST["create"]) && $_REQUEST["create"] == true){	  
 $username=$_REQUEST['username'];
 $pass=$_REQUEST['pass'];
 $fn=$_REQUEST['fn'];
 $ln=$_REQUEST['ln'];
 $email=$_REQUEST['em'];
 $tel=$_REQUEST['tel'];
 $adress=$_REQUEST['adr'];
 $city=$_REQUEST['city'];
 $country=$_REQUEST['country'];
 $encryptpass=md5($pass);


    if (empty($username) || empty($pass) ||
    empty($fn) || empty($ln) || empty($email) || empty($tel) || empty($adress) || empty($city) || empty($country)) {
    $_SESSION['error'] = "You Must Fill In All The Boxs."; }

    else {

$query = "insert into users (name,pass,firstname,lastname,email,phone,adress,city,country) values ('$username',
'$encryptpass','$fn','$ln','$email','$tel','$adress','$city','$country')";

if (mysql_query ($query)) {
?><script>alert('user created');</script><?php

$_SESSION['user']=$_REQUEST['username'];
$_SESSION['pass']= $encryptpass;
$_SESSION['name']=$_REQUEST['fn'];
$_SESSION['loggedin'] = true;

header("Location: index.php");
}
else {
echo "Couldnt Create User?";
}
	 };
};

?>
    <?php 
			 if (isset ($_SESSION['error'])) {
			 $error = $_SESSION['error'];
			 echo "<h3 style='color:purple;'> $error </h3>";
			 }
			 ?>

 <form action="signup.php?create=true" method="post">
Username : <br /><input type="text" name="username"  /><br /><br />
Password : <br /><input type="text" name="pass"  /><br /><br /><br>

First Name : <br /><input type="text" name="fn"  /><br /><br />
Last Name : <br /><input type="text" name="ln"  /><br /><br /><br>

Email : <br /><input type="text" name="em"  /><br /><br />
Phone : <br /><input type="text" name="tel"  /><br /><br /><br>

Address:<br />
<textarea name="adr" style="width:130px; height:70px;" ></textarea>
<br />

City : <br /><input type="text" name="city"  /><br /><br />
Country: <br /><input type="text" name="country"  /><br /><br />

          <input type="submit" value="Create User"  />
          
          </form>

</center>

</body>

</html>
0

thnx alot designer_101 ,,it works very good ...how can i add a reputation to u? and i still have a small problem .....a delete quey is not working ..it dosen't give me errors nor delete the selected row ...it's in the delete.php .....and send for me the link to add a reputation for u ...thnx alor

0

thnx alot designer_101 ............reputation added :D ...i did not see the link .........i'm quit nuts these days .....because of exams :S

0

Hi

Thanks for adding :)
Yeh, i'm only 15 so i've got my exams too :(

But anywho, i'l have a look at the code when I get home and get your delete query working. If its something that needs urgently doing in the next few hours make a new topic and post your query. someone will help you :)

Thanks again

0

not soo urgent .......when u have time ....do it for me ....and thnx for help

1

Hi

Here is your system fully working with the new delete function and working 'current online users' function.

All you need to do to complete it is the update page. Like before, if you need any help. Just ask, I already have the code, just give me something to work with so I dont have to create the whole thing myself. You know your code better :)

Hope this helps

Votes + Comments
Keep fighting the good fight ;)
Attachments
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
  <title></title>
</head>

<body>

<?php
$sub=$_REQUEST['sub'];
$desc=$_REQUEST['desc'];
$user = $_SESSION['name'];

$sql="insert into topics (subject,author,description,tdate) values ('$sub','$user','$desc','2-2-2002')";
$res=@mysql_query($sql)
 or die(mysql_error());

$insertid=mysql_insert_id();



	header("Location: detailtopic.php?idt=$insertid");



?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
  <title></title>
</head>

<body>

<?php
$user=$_SESSION['user'];
$idt=$_REQUEST['idt'];
$title=$_REQUEST['title'];
$msg=$_REQUEST['msg'];
$dbh=@mysql_connect('localhost','root','')
or die ('Cannot Connect');



$sql="insert into comments (title,message,author,topicid) values ('$title','$msg','$user','$idt')";
$res=mysql_query($sql)
     or die('<p>Error creating joke table: ' .
     mysql_error() . '</p>');

  header("Location: detailtopic.php?idt=$idt");

?>

</body>

</html>
<?php

/* By having this all on the one page it is easier to edit your connection details without
having to go through all your other pages. Also this file should actually be places outside your public_html on your server otherwise
people have access to your mysql and all the users data is readable. Ask me if you have any problems
 */
 
$host = "localhost";
$user = "root";
$pass = "";
if (mysql_connect($host, $user, $pass)) {
// echo "Connection Made";
mysql_select_db ("daniweb")
or die ("Could not select database");
}
else {
echo "Couldnt Connect";
}            

?>
<?php

    session_start();
include "connect.php";

   ?><html>

<head>
  <title></title>
</head>

<body>

<?php
  $id=$_REQUEST['topic'];


           //$query="delete  from topics where id='$todelete'";

           $query ="DELETE FROM topics WHERE id =$id";
       
    if (mysql_query($query)) {
               

           echo "Topic Deleted Succesfully<br><a href='home1.php'>Home</a>";
		   } else {
		   echo "Error, try again";
		   }
          //echo '<meta http-equiv="Refresh" content="2; url=home1.php" />';


?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
  <title></title>
</head>

<body bgcolor=grey>

<?php
$idt=$_REQUEST['idt'];
$user=$_SESSION['name'];

$result=mysql_query('select * from topics');
if(!$result){
exit('no data found');
}

while ($row = mysql_fetch_array($result)) {
  if($row['id']== $idt){
  	$u=$row['author'];
     $sql="select count(*) from topics where author='$u'";
      $res=@mysql_query($sql);

   if(!$res){
    exit('no data found1');
    }
         echo ' <b><a href=index.php>Abdullah Forum</a> > <a href=home.php>Home</a> > <a href=detailtopic.php>'.$row['subject'].'</a><b><br><br>';
     	echo '<b>Subject :'.$row['subject']."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author: ".$row['author']."
     	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Posts :".$res[0]."<br>";
     	echo  'Description</b> :'.$row['description'];
     	echo '<hr>';



    }

 }


  $query = "SELECT * FROM comments";
  $result = mysql_query ($query)
    or die ("Query failed");

 while ($row = mysql_fetch_array($result)) {
    if($row['topicid'] == $idt){
    	$title=$row['title'];
    	$author=$row['author'];
    	$msg=$row['message'];
   print "<b>Title : $title &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Author :$author</b> <br> $msg <hr>";

   }
}

print "<a href=new_reply.php?idt=$idt>Reply To Thread</a>";


?>

</body>

</html>
<?php

    session_start();
include "connect.php";
$p = $_SESSION['pass'];
$query = "UPDATE users SET loggedin=1 WHERE  pass='$p' ";
mysql_query ($query) or die ("Query failed");
   ?>
<html>
      <meta http-equiv="Refresh" content="300; url=logout.php" />
<head>
  <title></title>
</head>

<body>

<?php



$username=$_SESSION['user'];

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

print "<table width=100% height=10% border=1 bordercolor=black>
<tr><td>Welcome &nbsp;&nbsp;&nbsp;&nbsp; $username</td>
<td><a href=logout.php>Logout</a></td></tr></table> ";
echo "<br><br>";



$query = "SELECT * FROM topics";
       $result = mysql_query ($query)
         or die ("Query failed");

       while ($row = mysql_fetch_array($result)) {
       print "<form action='#' method='post'>";
       print '<input type="checkbox" name="topics" value=';
       echo   $row['id'];
       echo     '">';
       print '<a href="detailtopic.php?idt=';
       echo  $row['id'];
       echo  '">'.$row['subject'].'</a>';
       print '&nbsp;&nbsp;&nbsp;<a href=update.php?idt=';
       print $row['id'];
       print ">Update Topic</a><b style='margin-left:10px;'><u><a href='delete.php?topic=".$row['id']."'>Delete Topic</a></u></b><br><hr>";

       //print "<a href=www.forum.com/update.php>Update</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=www.forum.com/update.php>delete</a>";
       }
       print "</form>" ;
$online = 0;
       echo '<a href="newtopic.php">Add New Topic</a>';
       $query1= "SELECT * FROM users";
       $res = mysql_query ($query1)
         or die ("Query failed");
		$num = mysql_num_rows($res);
          while ($r = mysql_fetch_array($res)) {
          if ($r['loggedin'] == 1) {
		  $online = $online + 1;
		  }
          }
echo "<br><br>There are currently ".$num." members regestered. <b>".$online." online!</b>";

       }

  else{
       	header("Location: logout.php");
  }

?>

</body>

</html>
<?php
session_start();
include "connect.php";
?>
<html>
<a href="index.php">Abdullah's Forum</a> > <a href="home.php">Home</a><br>
      <meta http-equiv="Refresh" content="300; url=logout.php" />
<head>
  <title></title>
</head>

<body>

<?php

$p = $_SESSION['pass'];
$query = "UPDATE users SET loggedin=1 WHERE  pass='$p' ";
mysql_query ($query) or die ("Query failed");

$username=$_SESSION['user'];

if(isset($_SESSION['user'])){
$online = 0;
print "<table width=100% height=10% border=1 bordercolor=black>
<tr><td>Welcome &nbsp;&nbsp;&nbsp;&nbsp; $username</td>
<td><a href=logout.php>Logout</a></td></tr></table> ";
echo "<br><br>";



$query = "SELECT * FROM topics";
       $result = mysql_query ($query)
         or die ("Query failed");

       while ($row = mysql_fetch_array($result)) {
       echo '<a href="detailtopic.php?idt=';
       echo  $row['id'];
       echo  '">'.$row['subject'].'</a><br><hr>';
       }
       echo '<a href="newtopic.php">Add New Topic</a>';


   $query1= "SELECT * FROM users";
       $res = mysql_query ($query1)
         or die ("Query failed");
		$num = mysql_num_rows($res);
          while ($r = mysql_fetch_array($res)) {
          if ($r['loggedin'] == 1) {
		  $online = $online + 1;
		  }
          }
echo "<br><br>There are currently ".$num." members regestered. <b>".$online." online!</b>";
       }
  else{
       	header("Location: logout.php");
  }

?>

</body>

</html>
<?php 
session_start();
include "connect.php";  //creates a connection with the database
?>
<html>
<head>
<title>Welcome</title>

<?php 

if (!isset ($_SESSION['loggedin']) || $_SESSION['loggedin'] != true) { ?>
  <h2>Welcome Guest</h2>
  <body bgcolor=grey >

  <b>You must login or become a user</b><br><br>
<form name="login" method="post" action="login1.php">
Username: <input type="text" name="un"><br>
Password:<input type="password" name="pass"><br>
Remember Me: <input type="checkbox" name="rememberme" value="1"><br>
<input type="submit" name="submit" value="Login!">
</form>

<a href="signup.php">Signup</a> <br><br><br>

<?php
} else {
?>
  <h2>Welcome <?php echo $_SESSION['name']; ?></h2>
  <body bgcolor=grey >

  <b>You are logged in</b><br><a href="logout.php">Logout</a><br><br><h3><a href="home.php">Home</a><br><br>
<?php
$pass = $_SESSION['pass'];
$query = "UPDATE users
SET loggedin=1 WHERE pass='$pass'";
mysql_query($query) or die (mysql_error());


$count = "SELECT COUNT(*) FROM topics";
$send = mysql_query($count) or die ("Couldnt count");
$collect = mysql_fetch_array($send); 
if ($collect[0] == 0) {
echo "There are no topics";
}

else {
$query = "SELECT * FROM topics";
$result = mysql_query($query) or die ("Couldnt do query");
while ($row = mysql_fetch_array($result)) {
       echo '<a href="detailtopic.php?idt=';
       echo  $row['id'];
       echo  '">'.$row['subject'].'</a><br><hr>';
}
}
}
?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>

<head>
<title></title>
</head>

<body>

<?php

$result=mysql_query('select * from users');
if(!$result){
exit('no data found');
}
$t=0;
$u=$_REQUEST['un'];
$p=$_REQUEST['pass'];

$encpass=md5($p);
$_SESSION['pass'] = $encpass;
while($row=mysql_fetch_array($result)){

if(($row['name']== $u) && ($row['pass']==$encpass)){
$t=1;
}
if($u=='admin'){
		if(($row['name']== $u) and ($row['pass']==$encpass)){
		$t=2;
		}
}


}


if($t==1){

$_SESSION['user']=$u;
$_SESSION['pass'] = $encpass;
$_SESSION['loggedin'] = true;
$_SESSION['name']=$u;


echo '<meta http-equiv="Refresh" content="2; url=home.php" />';

  print "<center>  Thank you for logging in, $u <br>

Click here if your browser does not automatically redirect you.</center>";





}
if($t==0){
	echo 'Couldnt Log You In';
}

    if($t==2){
	    $_SESSION['user']=$u;
$_SESSION['pass'] = $encpass;


        echo '<meta http-equiv="Refresh" content="2; url=home1.php" />';

         print "<center>  Thank you for logging in, $u <br>

			Click here if your browser does not automatically redirect you.</center>";
          }


?>
</body>
</html>
<?php
session_start();
include "connect.php";
$pass = $_SESSION['pass'];
$query = "UPDATE users
SET loggedin=0 WHERE pass='$pass'";
mysql_query($query) or die ("Couldnt update");
session_destroy();
?>
<html>

<head>
  <title></title>
</head>

<body>

<?php


         echo '<center><meta http-equiv="Refresh" content="2; url=index.php" />';
   echo 'You Have Been Logged out .. You Have To Sign in Again</center>';




?>

</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>
         <meta http-equiv="Refresh" content="300; url=logout.php" />
<head>
  <title></title>
</head>

<body>
<h1>Add topic</h1>
<?php
echo $_SESSION['user'];
?>

<form action="addtopic.php" method="post">
Subject :	<input type="text" name="sub"><br>
Description :<textarea name="desc" col="400" row="200"></textarea><br>
<input type="submit" value="Confirm new topic">
</body>

</html>
<?php

    session_start();
include "connect.php";

   ?>
<html>
      <meta http-equiv="Refresh" content="300; url=logout.php" />
<head>
  <title></title>
</head>

<body>

<?php
 if(isset($_SESSION['user'])){
$idt=$_REQUEST['idt'];


$sql="SELECT * FROM topics";
$res=@mysql_query($sql)
      or die('Query failed');

      while($row=mysql_fetch_array($res)){
               if($idt ==	$row['id']){
                $topic=$row['subject'];
                }
       }
                  echo ' <b><a href=index.php>Abdullah Forum</a> > <a href=home.php>Home</a> > <a href=detailtopic.php>'.$topic.'</a> > <a href=new_reply.php>Reply to thread</a><b><br><br>';
  print "Reply To Thread &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thread: $topic<br><br>";
  }
     else
                       {
                       	header("Location: logout.php");
                       }

?>
<form action="add_reply.php" method="post">
Title <input type="text" name="title"><br>
<input type="hidden" name="idt" value="<?php echo $idt; ?>">
Message <br><textarea row="800" col="800" name="msg">
</textarea><br>
<input type="submit" value="Submit Reply">
</form>

</body>

</html>
<?php
session_start();
include "connect.php";
?>
<html>
   <meta http-equiv="Refresh" content="300; url=logout.php" />
<head>
  <title></title>
</head>

<body bgcolor="#666666">
<center><h1>Sign Up</h1>

                  <?php

if (isset ($_REQUEST["create"]) && $_REQUEST["create"] == true){	  
 $username=$_REQUEST['username'];
 $pass=$_REQUEST['pass'];
 $fn=$_REQUEST['fn'];
 $ln=$_REQUEST['ln'];
 $email=$_REQUEST['em'];
 $tel=$_REQUEST['tel'];
 $adress=$_REQUEST['adr'];
 $city=$_REQUEST['city'];
 $country=$_REQUEST['country'];
 $encryptpass=md5($pass);


    if (empty($username) || empty($pass) ||
    empty($fn) || empty($ln) || empty($email) || empty($tel) || empty($adress) || empty($city) || empty($country)) {
    $_SESSION['error'] = "You Must Fill In All The Boxs."; }

    else {

$query = "insert into users (name,pass,firstname,lastname,email,phone,adress,city,country) values ('$username',
'$encryptpass','$fn','$ln','$email','$tel','$adress','$city','$country')";

if (mysql_query ($query)) {
?>User Created >> <a href="index.php">Go And Login</a><?php


header("Location: index.php");
}
else {
echo "Couldnt Create User?";
}
	 };
};

?>
    <?php 
			 if (isset ($_SESSION['error'])) {
			 $error = $_SESSION['error'];
			 echo "<h3 style='color:purple;'> $error </h3>";
			 }
			 ?>

 <form action="signup.php?create=true" method="post">
Username : <br /><input type="text" name="username"  /><br /><br />
Password : <br /><input type="text" name="pass"  /><br /><br /><br>

First Name : <br /><input type="text" name="fn"  /><br /><br />
Last Name : <br /><input type="text" name="ln"  /><br /><br /><br>

Email : <br /><input type="text" name="em"  /><br /><br />
Phone : <br /><input type="text" name="tel"  /><br /><br /><br>

Address:<br />
<textarea name="adr" style="width:130px; height:70px;" ></textarea>
<br />

City : <br /><input type="text" name="city"  /><br /><br />
Country: <br /><input type="text" name="country"  /><br /><br />

          <input type="submit" value="Create User"  />
          
          </form>

</center>

</body>

</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>
0

thank you very much .......i'l close mark as solved ....and if i need annything else i will make another topic ......thnx again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.