Member area section

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Naeem
Forum Commoner
Posts: 31
Joined: Tue Jul 07, 2009 12:48 pm

Member area section

Post 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.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Member area section

Post by McInfo »

Maybe the query on line 36 needs a WHERE clause.

Edit: This post was recovered from search engine cache.
Post Reply