Hi
I have this code and the code is working very well but I have an error :
Notice: Undefined index: id in /var/www/core/myaccount.php on line 9

Here is my code:

<?php
session_start();
require_once('inc/config.php');
require_once('inc/header.php');
require_once('inc/functions.php');
login();
if(!$_GET['id']) { header("Location: index.php");}

switch($_SESSION['id']) {

   case $_GET['id']:

$id    = $_GET['id'];
    $query = mysql_query("SELECT * FROM users WHERE id='".$id."'");
    while($row = mysql_fetch_array($query)){;
   if($row[0]>0) {
 echo "<br />"."مرحباً بك في ملفك الشخصي : ".$row['username'];
 echo "<br />"."<img src='".$row['logo']."' />";
 echo "<br />"."إسم الشركة المسجل لدينا : ".$row['company_name'];
 echo "<br />"."رقم هاتف الشركة المسجل لدينا : ".$row['company_phone'];
 echo "<br />"."مكان الشركة المسجل لدينا : ".$row['company_location'];
 echo "<br />"."<a href='editpro.php?id=".$row['id']."'>تعديل ملفك الشخصي</a>";
 }else {
    echo "لقد حددت رقم عضوية غير صحيح";
    header("Refresh: 5;index.php");
}}
break;

    default:
    $id    = $_GET['id'];
    $query = mysql_query("SELECT * FROM users WHERE id='".$id."'");
    while($check = mysql_fetch_array($query)){;
   if($check[0]>0) {

echo "<br />"."الملف الشخصي لشركة : ".$check['company_name'];
echo "<br />"."<img src='".$check['logo']."' width='200' height='200' />";
echo "<br />"."هاتف الشركة : ".$check['company_phone'];
echo "<br />"."مكان الشركة : ".$check['company_location'];
}else {
    echo "لقد حددت رقم عضوية غير صحيح";
    header("Refresh: 5;index.php");
}}

    break;

}




?>

It works? The results might be unpredictable.

In line 9 the id in $_SESSION['id'] is not existing. So better check for existence before using it:

if(isset($_SESSION['id'])) {
    switch($_SESSION['id']) {
    ...

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.