www.webdeveloper.com
Results 1 to 4 of 4

Thread: Problems with Dynamic menu with php php and mysql

  1. #1
    Join Date
    Jun 2014
    Posts
    3

    Problems with Dynamic menu with php php and mysql

    Dynamic menu with php php and mysql
    Hello i developed a dynamic menu with php and mysql, but the text of the menu overlaps or duplicate.

    Here's the css code:
    Code CSS:
    body{ margin-top:0px; top:0px; background-image:url(fondo.png); margin-left:200px; height:200px; background-repeat:no-repeat}
    #principal{ width:800px; height:200px; }
    #header{ width:800px; height:360px; float:left}
    #main{ width:1000px; height:250px; float:left}
    #menu{ width:200px; height:400px; ; float:left; padding-top:4px }
    .boton{ width:150px; height:25px; color:#FFFFFF; ; float:left; padding-top:5px; font-size: 1.0em;}
    .url{ color:#FFFFFF; text-decoration:none; }
    #contenido{ width:720px; height:300px; float:left; margin-left:-20px }
    #ima_budin{ width:300px; height:250px; float:left}

    ////////////

    Here's the php code:

    PHP Code:
    <?php
    require_once("conexion.php");
    if(isset($_GET["id"]) ){

    $sql="select texto from contenido where id_menu=". $_GET["id"] ." ";
    } else
    {
    $sql="select texto from contenido where id_menu=1 ";
    }
    $res = mysql_query($sql, $con);
    if ($reg=mysql_fetch_array($res))
    {
    $contenido = $reg["texto"];
    }


    ?>
    <html>
    <head>

    <title>Untitled Document</title>

    <head>
    <link rel="stylesheet" type="text/css" href="theme.css">
    </head>
    </head>

    <body>
    <div id="principal"><div id="header">
    </div>
    <div id="main">
    <div id="menu">
    <?php
    $sql = "select * from menu";
    $res = mysql_query($sql,$con);
    while ($reg = mysql_fetch_array($res))
    {
    ?>
    <div class="boton"><a href="delibery.php?id=<?php echo $reg["id_menu"];?>" class="url"><?php echo $reg["texto"]; ?></a></div>

    <?php
    }
    ?>



    </div>

    <div align="center" id="contenido">

    <?php echo $contenido; ?></div>
    g
    </div>

    </div>
    </body>
    </html>
    and here's the php site:

    http://argentvision2.*****.org/carlos/delibery.php?id=1

    What do i have to do so that the menu stops overlaping

    Thanks
    Mariano Alippi.

  2. #2
    Your domain got masked, so I can't see it live -- BUT:

    1) This is 2014 not 2004, why are you still using mysql_ functions despite the giant red warning boxes in the manual?

    2) Dumping $_GET into a query string with no sanitation is just BEGGING to get hacked.

    3) Not sure what you're entire first <?php ?> block is even supposed to accomplish.

    4) Might help to stop opening/closing PHP so much.

    5) You probably also shouldn't be using attributes like ALIGN which have no business in any HTML written after 1997

    6) If it's a menu it should be a list, not DIV...

    7) if all your anchors are getting the same class none of them need classes.

    Hard to weigh in more without seeing the data that's being passed to the menu.

  3. #3
    Join Date
    May 2014
    Posts
    77
    I just had a look at your site, it doesn't look too bad, but..

    Please, before you do anything else and before you consider what you've done wrong... This will stop you getting hacked today. At this pointed if I wanted I could most probably delete your menu. (I wouldn't, but not everyone's as nice as me)

    Change
    PHP Code:
    $sql="select texto from contenido where id_menu="$_GET["id"] ." "

    to

    $sql
    ="select texto from contenido where id_menu=". (int)$_GET["id"]; // This is not the proper method, and you need more changes too, but this is a quick fix to save your site while you consider what you should do 

  4. #4
    Join Date
    Jun 2014
    Posts
    3
    Thank you for your answers, i'll make the changes to improve the security of the site, and also try to create a list for the menu not a div.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles