SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Jun 2012
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question problem accured while get the msg undefined index

    Hello Friends,

    i am working on a site.. i got the noticeable error page, i wrote: "notice: Notice: undefined index: user_name in c path.
    c:\xampp\htdocs\index.php on line
    118" how can i get rid of this writing.

    code is bellow

    <?PHP
    session_name("Metin2Corona");
    session_start();
    require("./conectare/config.inc.php");
    require("./conectare/rights.inc.php");
    require("./conectare/functions.inc.php");
    $sqlHp = mysql_connect(SQL_HP_HOST, SQL_HP_USER, SQL_HP_PASS);
    $sqlServ = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS);
    if(!is_resource($sqlServ) OR !is_resource($sqlHp)) {
    echo("header('Location: /error/404.php');");}
    echo '<?xml version="1.0"?>';
    mysql_query("SET NAMES UTF8");
    ?>
    <!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">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?PHP echo $serverSettings['titel_page']; ?></title>
    <!-- CSS -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/style.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/slider.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/fancybox.css" />
    <style type="text/css">
    <!--
    .style1 {color: #00FFFF}
    .style4 {font-size: 12px; }
    -->
    </style></head><body>
    <!-- header-->
    <div id="header">
    <div class="w960">
    <!-- navbar - left -->
    <div id="navleft" class="navbar"><ul>
    <li><a class="s1" href="index.php">Acasa</a></li>
    <?PHP
    if(isset($_SESSION['user_admin']) && checkInt($_SESSION['user_admin']) && $_SESSION['user_admin']>=0) {
    echo'
    <li><a class="s3" href="index.php?s=descarcare">Descarcare</a></li> ';
    }
    else
    {
    ?>
    <li><a class="s3" href="index.php?s=inregistrare">Inregistrare</a></li>
    <?PHP
    }
    ?>
    <?PHP
    if(isset($_SESSION['user_admin']) && checkInt($_SESSION['user_admin']) && $_SESSION['user_admin']>=0) {
    echo'
    ';
    }
    else {
    ?>
    <?PHP
    }
    ?>
    </ul></div>
    <!-- logo -->
    <div id="logo">
    <a href="#" title="SERVERNAME"></a></div>
    <!-- navbar - right -->
    <div id="navright" class="navbar"><ul>
    <li><a class="s2" href="index.php?s=galerie">Galerie</a></li>
    <li><a class="s3" href="index.php?s=clasament-bresle">Clasament</a></li>
    </ul></div></div></div>
    <!-- main -->
    <div id="main">
    <div class="w960">
    <!-- sidebar:left -->
    <div id="sb-left" class="sidebar">
    <!-- Panou logare -->
    <div class='boxui box-title'>
    <span class='title-icon icon-user'></span>
    <h3>Autentificare</h3></div>
    <div class='boxui box-con'>
    <?php
    if ( $_SESSION ["user_name"] == "") {
    ?>
    <form id="login" action="index.php?s=login" method="post">
    <div><input class="bar curved5" AUTOCOMPLETE="off" type="text" class="validate[required,custom[noSpecialCharacters],length[3,16]]" id="username" name="user" maxlength="16" onfocus="if(this.value=='Nume de utilizator') this.value='';" onblur="if(this.value=='') this.value='Nume de utilizator';" value="Nume de utilizator"/>
    <Br><input class="bar curved5" AUTOCOMPLETE="off" type="password" class="validate[required,length[5,16]]" id="password" name="pw" maxlength="16" onfocus="if(this.value=='Parola') this.value='';" onblur="if(this.value=='') this.value='Parola';" value="Parola"/><Br>
    <input class="btn s1" type="submit" name="login" value="Login"/>
    <a href="index.php?s=inregistrare"><input class="btn s2" type="button" name="Login" value="inregistrare" /></a></div>
    </form>
    <div class="sb-sep"></div>
    <?php
    } else {
    ?>
    &nbsp;&nbsp;&nbsp;&nbsp;<img src='img/nota3.png' alt='' width='10' height='10' /><a href='index.php?s=utilizator' class='xlinks'>Datele utilizatorului</a></p>
    &nbsp;&nbsp;&nbsp;&nbsp;<img src='img/nota3.png' alt='' width='10' height='10' /><a href='/itemshop/index.php' class='xlinks'>Incarca Monede Dragon</a></p>
    &nbsp;&nbsp;&nbsp;&nbsp;<img src='img/nota3.png' alt='' width='10' height='10' /><a href='index.php?s=delogare' class='xlinks'>Delogare</a></p>
    <?PHP
    }
    ?>
    </span><br />
    </div>
    <div class="boxui box-end"></div>
    <!-- Butoane Speciale -->
    <a class="sb-special sb-download" href="index.php?s=descarcare">Descarcare</a>
    <a class="sb-special sb-community" href="http://annhelps.wikiforum.ro">Forum</a>
    <!-- Sponsor -->
    <div class="boxui box-title">
    <span class="title-icon icon-status"></span>
    <h3>Reclama</h3>
    </div>
    <div class="boxui box-con">
    <div class="clearfix"></div>
    <center>
    <a class="curved5" href="http://google.ro/"><img src="img/reclama.gif" alt="" /> <span></span></a></center>
    <div class="sb-sep"></div>
    </div>
    <!-- Facebook -->
    <div class="boxui box-end"></div></div>
    <!-- end sidebar:left -->
    <?PHP
    $includeDir = ".".DIRECTORY_SEPARATOR."pagini".DIRECTORY_SEPARATOR;
    $includeDefault = $includeDir."acasa.php";
    if(isset($_GET['s']) && !empty($_GET['s'])){
    $_GET['s'] = str_replace("\0", '', $_GET['s']);
    $includeFile = basename(realpath($includeDir.$_GET['s'].".php"));
    $includePath = $includeDir.$includeFile;
    if(!empty($includeFile) && file_exists($includePath))
    {
    include($includePath);
    }
    else
    {
    include($includeDefault);
    }
    }
    else
    {
    include($includeDefault);
    }
    ?>
    <!-- sidebar:right -->
    <div id="sb-right" class="sidebar">
    <?PHP
    if(isset($_SESSION['user_admin']) && checkInt($_SESSION['user_admin']) && $_SESSION['user_admin']>=0) {
    ?>
    <?PHP
    }
    ?>
    <div class="boxui box-title">
    <span class="title-icon icon-status"></span>
    <h3>Statistici joc<span class="boxui box-con sb-status">
    </span></h3>
    </div>
    <div class="boxui box-con sb-status">
    <p class="on"/>
    <?php
    $serverip = "5.93.47.100";
    $ip = gethostbyname($serverip);
    $portlist=array(3306);
    $status=array("<p><font color=#6189ae><span>&bull;</span>Autentificarea este</font>");
    $i=0;
    foreach ($portlist as $port){
    $online = @fsockopen($ip, $port, $errno, $errstr, 1);
    if (!$online)
    {
    echo "".$status[$i]." <font color=red>inchisa!&nbsp;&nbsp;&nbsp;</font>";
    }
    else
    {
    echo "".$status[$i]." <font color=green>deschisa!&nbsp;&nbsp;&nbsp;</font>";
    }
    @fclose($online);
    $i++;
    }
    ?>
    <div class="sb-sep"></div><span>
    <p> <font color=#6189ae><span>&bull;</span>300% rata experienta</font></p><div class="sb-sep"></div>
    <p> <font color=#6189ae><span>&bull;</span>300% dropul yang</font></p><div class="sb-sep"></div>
    <p> <font color=#6189ae><span>&bull;</span>300% dropul itemelor</font></p><div class="sb-sep"></div>
    </span></p>
    </div>
    <div class="boxui box-end"></div>
    <!-- Trailer -->
    <div class="boxui box-title">
    <span class="title-icon icon-vid"></span>
    <h3>Trailer</h3>
    </div>
    <div class="boxui box-con">
    <div class="clearfix"></div>
    <a id="sbvid" class="curved5" href="http://youtu.be/Bww9paJt9jo"><img src="img/screenshots/video2.jpg" alt="" /> <span></span></a>
    <div class="sb-sep"></div>
    </div>
    <!-- Clasament jucatori -->
    <div class="boxui box-title">
    <span class="title-icon icon-status"></span>
    <h3>Clasament jucatori</h3>
    </div>
    <div class="boxui box-con">
    <div class="clearfix"></div>
    <?PHP include("./conectare/top10.php"); ?>
    <a href="index.php?s=clasament-jucatori" class="ilink">Clasament intreg</a></div>
    <div class="boxui box-end"></div>
    <!-- Clasament Bresla -->
    <div class="boxui box-title">
    <span class="title-icon icon-status"></span>
    <h3>Clasament bresle</h3>
    </div>
    <div class="boxui box-con">
    <div class="clearfix"></div>
    <?PHP include("./conectare/top5_g.php"); ?>
    <a href="index.php?s=clasament-bresle" class="ilink">Clasament intreg</a> </div>
    <div class="boxui box-end"></div>
    </div>
    <!-- end sidebar:left -->
    </div>
    </div>
    <!-- footer -->
    <div id="footer">
    <div class="w960">
    <!-- logo -->
    <div class="left">
    <p><a href="http://annhelps.wikiforum.ro"><img src="img/logo_small.png" alt="Metin2Corona" /></a>
    &copy 2012 Metin2Corona publicat de <a href="http://annhelps.wikiforum.ro">Koronastar</a>.Toate drepturile rezervate.</p>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <!-- JS -->
    <script type="text/javascript" src="../ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    <script type="text/javascript">!window.jQuery && document.write('<script src="css/js/jq.min.js"><\/script>')</script>
    <script type="text/javascript" src="css/js/fancybox.js"></script>
    <script type="text/javascript" src="css/js/slider.js"></script>
    <script type="text/javascript" src="css/js/init.js"></script>
    <script type="text/javascript">
    <!--
    function abreJanela(URL) {
    location.href = URL; //
    }
    //-->
    </script>
    </body>
    </html>
    Thanks in advanced...

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,173
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Your conditional tests if it's empty but doesn't test if it's isset() first.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    I'd do something like this:

    PHP Code:
    if (empty($_SESSION["user_name"])) {
        ...

    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •