Page 1 of 1

Member area section

Posted: Sun Aug 09, 2009 2:25 am
by Naeem
Assalam-O-Walaikum and hi to all my dear friends,
I have made a member area successfully.
Regisrtation system,login system all are fine but in database there is two tables i have made one for members login and passwords and one for members data.
How to retrieve and insert data only in members account because when i insert data it is shown to all members i want that members can only views his inserted data how to do that?
Here is my member area page:

Code: Select all

<?php
session_start();
include '../inc/connection.php';
include '../inc/functions.php';
if($_SESSION['auth'] !="yes"){
    header("Location: login.php");
    exit();
}
    css();
if($_GET['do']){
        session_destroy();
        echo "<center>You are now logout.&nbsp;<a href = 'login.php' >Go to Login Page</a></center>";
      }
else{
    echo "<center>Welcome to Admin Area $_SESSION[user]&nbsp;<a href = 'member.php?do=logout' >LogOut</a>";
    echo "<br /><center><table border = '1'><form action = 'member.php' method = 'POST'>
      <tr><td>Roll No:</td><td><input type = 'text' name = 'roll_no' /></td></tr>
      <tr><td>Marks:</td><td><input type = 'text' name = 'marks' /></td></tr>
      <input type = 'hidden' name = 'post' value = 'true' />
      <tr><td><input type = 'submit' value = 'Submit' /></td></tr>
      </form></table></center><br />";
        if(isset($_POST['post'])){
        $roll_no = cleanString($_POST['roll_no']);
        $marks = cleanString($_POST['marks']);
        $select_data3 = mysql_query("SELECT * FROM result WHERE rollno = '$roll_no'");
        $num = mysql_num_rows($select_data3);
        if($num > 0){
            echo "Roll no: $roll_no Already Exist<br />";
        }
        else{
      $ins_name = mysql_query("INSERT INTO result(rollno,marks)VALUES($roll_no,$marks)");
      echo "Result Successfully inserted<br />";
      }
     }
     echo "<center><table border = '1' width = '50%'><tr><th>Roll No</th><th>Marks</th><th>Moderation</th></tr>";
     $select_data = mysql_query("SELECT * FROM result ORDER BY id");
     if(!$select_data){
    echo "Could'nt select data";
}
$num = mysql_numrows($select_data);
if($num <= 0){
    echo "<center>No results found or you enter a wrong roll no if you are facing any difficulties <a href = 'contact.php'>Contact Us</a></center>";
}
while($row = mysql_fetch_assoc($select_data)){
    $id = $row['id'];
    echo "<tr><td>".$row['rollno']."</td>";
    echo "<td>".$row['marks']."</td>";
    echo "<td><a href = 'edit.php?do=edit&id=$id'>Edit</a>&nbsp;&nbsp;&nbsp;<a href = 'edit.php?do=del&id=$id'>Delete</a></td>";
}
echo "</table><center>";
}
?>
Thanks.
Allah Hafiz.

Re: Member area section

Posted: Sun Aug 09, 2009 10:52 am
by McInfo
Maybe the query on line 36 needs a WHERE clause.

Edit: This post was recovered from search engine cache.