php project

Discussion in 'PHP' started by swatistarster, Jul 28, 2012.

  1. #1
    hi!I have a problem in running this project.I am attaching all files of my project.Please download and check if anyone can rectify it.open index.html in browser.then select a anything from list ,check scada and click go button.But next page will not open.this is the main problem
     

    Attached Files:

    swatistarster, Jul 28, 2012 IP
  2. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #2
    Since you are a newcomer with just 1 post maybe you could use the
     tags instead of zip file.
    Code (markup):
     
    Arttu, Jul 28, 2012 IP
  3. swatistarster

    swatistarster Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Bt code code is too large to post thats why i use zip file.
     
    swatistarster, Jul 30, 2012 IP
  4. coun_vincent

    coun_vincent Well-Known Member

    Messages:
    803
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Nobody will download it and check it for sure .... there's some Security Norms applied on the newcomer :)

    so , Please just Post your code as Tag code and don't worry if it's large or too big .

    thanks and good luck
     
    coun_vincent, Jul 30, 2012 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    1) I was willing to download and take a look, since I can look at the source BEFORE trying to run it (duh guys, REALLY?)

    2) if you are talking about testing locally, of course it won't work... since most people won't have PHP installed or mySQL for that matter, much less have the databases you are calling set up.

    3) Your code is hard to deal with because you've got so much stuff just crammed into a single file -- stuff that in production should be in separate files anyways like the static CSS, the static scripting, and the bits of HTML that are shared by both the HTML file, and the PHP it's calling... That you're sending obvious screen CSS to "all" also seems a bit odd... that you're using DIV to do LABEL's job goes with the outdated markup techniques you seem to be using...

    Now putting all that aside, you have a malformed form, you seem to be playing some form of scripted redirection nonsense and a ton of pointless javascript for christmas knows what.

    I'm not entirely sure what it is you're trying to accomplish with this, I'm just pretty sure you've WAY over-thought something simple...

    Instead of this:
    echo "<script>window.location = 'location.php'</script>";

    You should probably be using a HTTP redirect as that's far more likely to actually work.

    Naturally as I tell pretty much everyone I'd take that jquery asshattery you seem to have and kick that in it's arse. I would consider storing the data you're accessing with SELECT/OPTION in the same format as the content to save bandwidth -- that way you don't have to set VALUE. In general you seem to be doing a bunch of pointless **** in javascript that should either be handled server side or using HTML/CSS.

    Oh, and you do know your using that redirect with window.location erases all your postdata, right? Seriously I'm trying to figure out what the devil you're trying to accomplish with this pointless wasteful nonsense:
    
    <?php
    session_start();
    if(isset($_POST['location']) && isset($_POST['option']))
    {
    $_SESSION['location']=$_POST['location'];
    if($_POST['option']=="op_1")
    echo "<script>window.location = 'location.php'</script>";
    }
    ?>
    
    Code (markup):
    ...apart from erasing the POST-data so location.php isn't being sent anything. Why isn't it just sending to location.php and checking 'option' there?!?

    Also not sure why you're wasting time setting up PHP sessions and then not using them for anything. (not that I know many developers who use php sessions in this day and age -- much less mysql_ functions instead of PDO or mysqli)

    Looking deeper -- do you have a separate table for every LOCATION?!? I dunno, your query in add_loc.php is gibberish.
     
    Last edited: Jul 30, 2012
    deathshadow, Jul 30, 2012 IP
  6. swatistarster

    swatistarster Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hey! actually i made it in group.and all php and mysql part is done by someone else.I dont know php and mysql .I hav done the html and designing part only.this whole is running on her laptop who created that php mysql part.Bt when she gave me whole application integrated.It is not running on my laptop.
    If you can find out why it is not ruunning please try to solve it bcoz i dont know php nd mysql in deep.
    I think maybe problem is with database.she gave me database in localhost.sql file .Is it correct file to give whole database frm one laptop to another.
     
    swatistarster, Jul 31, 2012 IP
  7. swatistarster

    swatistarster Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    here is the code:
    Index.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
    <head profile="http://gmpg.org/xfn/11">
    <title>IP_Portal</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="description" content="IP_Portal" />
    <meta name="keywords" content="IP_Portal" />
    <style type="text/css" media="screen,projection">
    /*<![CDATA[*/
    body{color:#222;font:80%/150% verdana,geneva,sans-serif;margin:2em auto;padding:0;}
    body blockquote{background:#f5F5F5;font-size:1em;padding:0.5em 1em;text-indent:2em;}
    body blockquote p{margin:0.5em 0;line-height:150%;}
    body blockquote,body h3,body h4,dl dt.def-head,body div.readme-subtitle{color:#000;font-family:georgia,times,serif;}
    body code{font:1em/133% "courier new",courier,monospace;}
    body div.readme{margin:0 auto 10em;width:40em;}
    body div.readme-subtitle{color:#000;line-height:150%;margin:0 25%;padding:1em 0;}
    body div.readme-version{color:#888;}
    body h2{color:#28425e;font:normal 3.2em/150% arial,helvetica,sans-serif;letter-spacing:2px;margin:0;text-align:center;}
    body h3{font:1.7em/133% georgia,times,serif;margin:2em 0 -0.5em;}
    body h4{font-size:1.4em;font-style:italic;font-weight:400;line-height:150%;margin:1em 0 -0.5em;}
    body ol#toc h3{margin-bottom:0;}
    body ol li form{float:left;margin:1.5em 1em 0 0;}
    body p{margin:1em 0;}
    body p.rubric{margin:1em 0 0.2em;}
    div.readme-meta{font-size:0.9em;letter-spacing:2px;line-height:133%;text-align:center;}
    dl{background:#eee;padding:1em;}
    dl dd{margin:0;padding:0;}
    dl dd code{color:#666;font-size:0.9em;}
    dl dd.example{margin-left:1em;margin-bottom:2em;}
    dl dt code{display:block;font-size:1.1em;margin:0.3em 0;}
    dl dt.rubric{margin-top:1em;}
    dl dt.def-head{font-size:1.2em;font-weight:bold;line-height:150%;margin-left:-1em;margin-right:-1em;padding:0 1em 0;}
    dl dd.def-rubric{border-bottom:2px solid #fff;line-height:150%;font-style:italic;margin-left:-1em;margin-right:-1em;padding:0 1em 0.5em;}
    /*]]>*/
    </style>
    <style type="text/css" media="all">
    /*<![CDATA[*/
    body blockquote strong{text-transform:uppercase;}
    body div.readme p#friends span.family-name{display:none;}
    body ol#toc{list-style:lower-roman;}
    body ul li{list-style:square;}
    body ul li ul li{list-style:circle;}
    body ol.item-examples li{list-style:lower-alpha;}
    dl{margin:1em 0 2em;}
    div#theme-meta span{display:block;margin:0.2em 0;}
    dl#emphasis dd em{font-style:normal;font-weight:700;}
    dl#emphasis dd strong{font-size:0.9em;letter-spacing:0.4px;text-transform:uppercase;}
    dl dd a.download{background:url(images/file-download.png) no-repeat center left;padding-left:19px;}
    dl dd p.html{background:url(images/file-html.png) no-repeat center left;padding-left:19px;margin:0;}
    dl dd span.pdf{background:url(images/file-pdf.png) no-repeat center left;padding-left:19px;margin:0;}
    dl dd a.zip{background:url(images/file-zip.png) no-repeat center left;padding-left:19px;margin:0;}
    dl dd p.important{background:#f5f5dc url(images/important.png) no-repeat 0.5em center;border-bottom:1px solid #d0d0bb;border-top:1px solid #d0d0bb;padding:0.2em 0.5em 0.2em 2.2em;margin:0;}
    dl dd span.caps{font-variant:small-caps;}
    /*]]>*/
    </style>
    <style type="text/css">
    /* Two custom themes */
    .dk_theme_orange {
    background: #ffffff; /* Old browsers */
    background: -moz-linear-gradient(top, #ffffff 0%, #f1f1f1 50%, #e1e1e1 51%, #f6f6f6 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(50%,#f1f1f1), color-stop(51%,#e1e1e1), color-stop(100%,#f6f6f6)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #ffffff 0%,#f1f1f1 50%,#e1e1e1 51%,#f6f6f6 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #ffffff 0%,#f1f1f1 50%,#e1e1e1 51%,#f6f6f6 100%); /* Opera11.10+ */
    background: -ms-linear-gradient(top, #ffffff 0%,#f1f1f1 50%,#e1e1e1 51%,#f6f6f6 100%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f6f6f6',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(top, #ffffff 0%,#f1f1f1 50%,#e1e1e1 51%,#f6f6f6 100%); /* W3C */
    }
    .dk_theme_orange .dk_options a:hover,
    .dk_theme_orange .dk_option_current a {
    background-color: #E15A01;
    border-bottom-color: #604A42;
    color: #fff;
    text-shadow: #604A42 0 1px 0;
    }
    .dk_theme_orange .dk_toggle,
    .dk_theme_orange.dk_open .dk_toggle {
    background-color: transparent;
    }
    .dk_theme_orange.dk_focus .dk_toggle{
    box-shadow: 0 0 5px #E15A01;
    -moz-box-shadow: 0 0 5px #E15A01;
    -webkit-box-shadow: 0 0 5px #E15A01;
    }


    .dk_theme_black {
    background: #aebcbf; /* Old browsers */
    background: -moz-linear-gradient(top, #aebcbf 0%, #6e7774 50%, #0a0e0a 51%, #0a0809 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#aebcbf), color-stop(50%,#6e7774), color-stop(51%,#0a0e0a), color-stop(100%,#0a0809)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #aebcbf 0%,#6e7774 50%,#0a0e0a 51%,#0a0809 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #aebcbf 0%,#6e7774 50%,#0a0e0a 51%,#0a0809 100%); /* Opera11.10+ */
    background: -ms-linear-gradient(top, #aebcbf 0%,#6e7774 50%,#0a0e0a 51%,#0a0809 100%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#aebcbf', endColorstr='#0a0809',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(top, #aebcbf 0%,#6e7774 50%,#0a0e0a 51%,#0a0809 100%); /* W3C */
    }
    .dk_theme_black .dk_toggle,
    .dk_theme_black.dk_open .dk_toggle {
    background-color: transparent;
    background-image: url('dropkick/images/dk_arrows_white.png');
    color: #fff;
    text-shadow: none;
    }
    .dk_theme_black .dk_options a {
    background-color: #333;
    color: #fff;
    text-shadow: none;
    }
    .dk_theme_black .dk_options a:hover,
    .dk_theme_black .dk_option_current a {
    background-color: #E15A01;
    color: #fff;
    text-shadow: #604A42 0 1px 0;
    }




    .awesome, .awesome:visited {
    background: #222 url(/images/alert-overlay.png) repeat-x;
    display: inline-block;
    padding: 5px 10px 6px;
    color: #fff;
    text-decoration: none;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    text-shadow: 0 -1px 1px rgba(0,0,0,0.25);
    border-bottom: 1px solid rgba(0,0,0,0.25);
    position: relative;
    cursor: pointer;
    }


    .awesome:hover { background-color: #111; color: #fff; }
    .awesome:active { top: 1px; }
    .small.awesome, .small.awesome:visited { font-size: 11px; padding: ; }
    .awesome, .awesome:visited,
    .medium.awesome, .medium.awesome:visited { font-size: 13px; font-weight: bold; line-height: 1; text-shadow: 0 -1px 1px rgba(0,0,0,0.25); }
    .large.awesome, .large.awesome:visited { font-size: 14px; padding: 8px 14px 9px; }

    .green.awesome, .green.awesome:visited { background-color: #91bd09; }
    .green.awesome:hover { background-color: #749a02; }
    .blue.awesome, .blue.awesome:visited { background-color: #2daebf; }
    .blue.awesome:hover { background-color: #007d9a; }
    .red.awesome, .red.awesome:visited { background-color: #e33100; }
    .red.awesome:hover { background-color: #872300; }
    .magenta.awesome, .magenta.awesome:visited { background-color: #a9014b; }
    .magenta.awesome:hover { background-color: #630030; }
    .orange.awesome, .orange.awesome:visited { background-color: #ff5c00; }
    .orange.awesome:hover { background-color: #d45500; }
    .yellow.awesome, .yellow.awesome:visited { background-color: #ffb515; }
    .yellow.awesome:hover { background-color: #fc9200; }
    </style>








    <link rel="stylesheet" href="dropkick/dropkick.css" type="text/css">
    <script type="text/javascript" src="jquery.js"></script>
    <script src="dropkick/jquery.dropkick-1.0.0.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    $(function () {
    $('.default').dropkick();


    $('.black').dropkick({
    theme : 'black'
    });


    $('.change').dropkick({
    change: function (value, label) {
    alert('You picked: ' + label + ':' + value);
    }
    });


    $('.existing_event').dropkick({
    change: function () {
    $(this).change();
    }
    });


    $('.custom_theme').dropkick({
    theme: 'black',
    change: function (value, label) {
    $(this).dropkick('theme', value);
    }
    });


    $('.dk_container').first().focus();
    });
    </script>


    </head>
    <body>






    <div class="readme">
    <h2 id="readme-title">IP_Portal</h2>
    <div class="readme-meta">
    <div class="readme-version">Version 0.1</div>
    <div class="readme-subtitle"></div>
    </div>


    <form action="main_act.php" method="post" accept-charset="utf-8" class="example_form">
    <select name="location" class="default" tabindex="2">
    <option value="">Location</option>
    <option value="Chandkheda">Chandkheda</option>
    <option value="Limbodra_GGS2">Limbodra GGS2</option>
    <option value="S_Kadi_GGS">S Kadi GGS1</option>
    <option value="S_Kadi_GGS2">S Kadi GGS2</option>
    <option value="Wasna_GGS1">Wasna GGS1</option>
    <option value="Wasna_GGSR">Wasna GGSS</option>
    <option value="Jhalora_GGS01">Jhalora GGS01</option>
    <option value="Jhalora_GGS02">Jhalora_GGS02</option>
    <option value="Limbodra_GGS01">Limbodra GGS01</option>
    <option value="Limbodra_GGS02">Limbodra GGS02</option>
    <option value="Viraj_GGS1">Viraj GGS1</option>
    <option value="Viraj_GGSR">Viraj GGSR</option>
    <option value="Sanand_GGS01">Sanand GGS01</option>
    <option value="Sanand_GGS02">Sanand GGS02</option>
    <option value="Nandej_GGS01">Nandej GGS01</option>
    <option value="Nandej_GGS02">Nandej GGS02</option>
    <option value="Kalol_GGS01">Kalol GGS01</option>
    <option value="Kalol_GGS02R">Kalol GGS02 SCADA TIER R</option>
    <option value="Kalol_GGS03">Kalol GGS03</option>
    <option value="Kalol_GGS04R">Kalol GGS02 SCADA TIER R</option>
    <option value="Kalol_GGS05R">Kalol GGS02 SCADA TIER R</option>
    <option value="Kalol_GGS07">Kalol GGS07</option>
    <option value="Kalol_GGS08R">Kalol GGS02 SCADA TIER R</option>
    <option value="Kalol_GGS09R">Kalol GGS02 SCADA TIER R</option>
    <option value="Kalol_GCS">Kalol GCS SCADA TIER 1</option>
    <option value="Kalol_GCSR">Kalol GCS SCADA TIER R</option>
    <option value="Kalol_GCSR">Kalol GCSR</option>
    <option value="Kalol_GGS021">Kalol GGS02 SCADA TIER 1</option>
    <option value="Kalol_CTF">Kalol CTF</option>
    <option value="Kalol_GGS041">Kalol GGS04 SCADA TIER 1</option>
    <option value="Kalol_GGS051">Kalol GGS05 SCADA TIER 1</option>
    <option value="Kalol_GGS061">Kalol GGS06 SCADA TIER 1</option>
    <option value="Kalol_GGS081">Kalol GGS08 SCADA TIER 1</option>
    <option value="Kalol_GGS091">Kalol GGS09 SCADA TIER 1</option>
    <option value="Kalol_GGS111">Kalol GGS11 SCADA TIER 1</option>




    </select>
    <input name="option" value="op_1" type="radio">
    <div style="display:inline;">Scada</div>
    <input name="option" value="op_2" type="radio">
    <div style="display:inline;">BWA</div>
    <input name="option" value="op_3" type="radio">
    <div style="display:inline;">Gateway</div>
    <input name="option" value="op_4" type="radio">
    <div style="display:inline;">IP Address</div>
    <button class="small awesome" type="submit">Go! &raquo;</button>
    </form>
    </body>
    </html>

    location.php :
    <?php session_start();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
    <head profile="http://gmpg.org/xfn/11">
    <title>IP_Portal</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="description" content="IP_Portal" />
    <meta name="keywords" content="IP_Portal" />
    <style type="text/css" media="screen,projection">
    /*<![CDATA[*/
    body{color:#222;font:80%/150% verdana,geneva,sans-serif;margin:2em auto;padding:0;}
    body blockquote{background:#f5F5F5;font-size:1em;padding:0.5em 1em;text-indent:2em;}
    body blockquote p{margin:0.5em 0;line-height:150%;}
    body blockquote,body h3,body h4,dl dt.def-head,body div.readme-subtitle{color:#000;font-family:georgia,times,serif;}
    body code{font:1em/133% "courier new",courier,monospace;}
    body div.readme{margin:0 auto 10em;width:40em;}
    body div.readme-subtitle{color:#000;line-height:150%;margin:0 25%;padding:1em 0;}
    body div.readme-version{color:#888;}
    body h2{color:#28425e;font:normal 3.2em/150% arial,helvetica,sans-serif;letter-spacing:2px;margin:0;text-align:center;}
    body h3{font:1.7em/133% georgia,times,serif;margin:2em 0 -0.5em;}
    body h4{font-size:1.4em;font-style:italic;font-weight:400;line-height:150%;margin:1em 0 -0.5em;}
    body ol#toc h3{margin-bottom:0;}
    body ol li form{float:left;margin:1.5em 1em 0 0;}
    body p{margin:1em 0;}
    body p.rubric{margin:1em 0 0.2em;}
    div.readme-meta{font-size:0.9em;letter-spacing:2px;line-height:133%;text-align:center;}
    dl{background:#eee;padding:1em;}
    dl dd{margin:0;padding:0;}
    dl dd code{color:#666;font-size:0.9em;}
    dl dd.example{margin-left:1em;margin-bottom:2em;}
    dl dt code{display:block;font-size:1.1em;margin:0.3em 0;}
    dl dt.rubric{margin-top:1em;}
    dl dt.def-head{font-size:1.2em;font-weight:bold;line-height:150%;margin-left:-1em;margin-right:-1em;padding:0 1em 0;}
    dl dd.def-rubric{border-bottom:2px solid #fff;line-height:150%;font-style:italic;margin-left:-1em;margin-right:-1em;padding:0 1em 0.5em;}
    /*]]>*/
    </style>
    <style type="text/css" media="all">
    /*<![CDATA[*/
    body blockquote strong{text-transform:uppercase;}
    body div.readme p#friends span.family-name{display:none;}
    body ol#toc{list-style:lower-roman;}
    body ul li{list-style:square;}
    body ul li ul li{list-style:circle;}
    body ol.item-examples li{list-style:lower-alpha;}
    dl{margin:1em 0 2em;}
    div#theme-meta span{display:block;margin:0.2em 0;}
    dl#emphasis dd em{font-style:normal;font-weight:700;}
    dl#emphasis dd strong{font-size:0.9em;letter-spacing:0.4px;text-transform:uppercase;}
    dl dd a.download{background:url(images/file-download.png) no-repeat center left;padding-left:19px;}
    dl dd p.html{background:url(images/file-html.png) no-repeat center left;padding-left:19px;margin:0;}
    dl dd span.pdf{background:url(images/file-pdf.png) no-repeat center left;padding-left:19px;margin:0;}
    dl dd a.zip{background:url(images/file-zip.png) no-repeat center left;padding-left:19px;margin:0;}
    dl dd p.important{background:#f5f5dc url(images/important.png) no-repeat 0.5em center;border-bottom:1px solid #d0d0bb;border-top:1px solid #d0d0bb;padding:0.2em 0.5em 0.2em 2.2em;margin:0;}
    dl dd span.caps{font-variant:small-caps;}
    /*]]>*/
    </style>
    </head>
    <body>
    <div class="readme">
    <h2 id="readme-title">IP_Portal</h2>
    <div class="readme-meta">
    <div class="readme-version"></div>
    <?php
    echo '<div class="readme-subtitle">Following are the IP addresses for '.$_SESSION['location'].'</div>';
    ?>

    </div>
    <?php
    echo '<div class="readme-subtitle"><dd>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$_SESSION['location'].'</dd></div>';
    ?>
    <?php
    //create a database connection
    ob_start();
    $connection = mysql_connect("localhost", "root", "team11");
    if(!$connection)
    {
    die("Database Connection Failed: " .mysql_error());
    }

    //select a database
    $db_select = mysql_select_db("ip_addr", $connection);
    if(!$db_select)
    {
    die("Database selection Failed: " .mysql_error());
    }

    $query="SELECT * FROM ".strtolower($_SESSION['location']);
    $result= mysql_query($query, $connection);
    if(!$result)
    {
    die("Database Query Failed: " .mysql_error());
    }
    $num=mysql_numrows($result);
    mysql_close($connection);

    $i=0;
    while ($i < $num) {


    $f=mysql_result($result,$i,"IP Address");
    echo $f;
    echo "<br />";


    ?>


    <?php
    $i++;
    }
    ?>
    <br />
    <form method="post" action="add_loc.php">
    Add IP Addr.--<br />
    <input type="text" name="ip" /><br />
    <input type="submit" value="Add" /><br />
    </form>




    </body>
    </html>

    main_act.php :
    <?php
    session_start();
    if(isset($_POST['location']) && isset($_POST['option']))
    {
    $_SESSION['location']=$_POST['location'];
    if($_POST['option']=="op_1")
    echo "<script>window.location = 'location.php'</script>";
    }
    ?>


    add_loc.php    :
    PHP:
    <?php
    session_start();


    if(isset($_POST['ip']))
    {
    //create a database connection
    $connection = mysql_connect("localhost", "root", "team11");
    if(!$connection)
    {
    die("Database Connection Failed: " .mysql_error());
    }

    //select a database
    $db_select = mysql_select_db("ip_addr", $connection);
    if(!$db_select)
    {
    die("Database selection Failed: " .mysql_error());
    }

    $query="INSERT INTO `ip_addr`.`".strtolower($_SESSION['location'])."` (
    `IP Address`
    )
    VALUES (
    '".$_POST['ip']."'
    );";
    mysql_query( $query, $connection);
    mysql_close($connection);

    echo "<script>window.location = 'location.php'</script>";
    }
    ?>


     
    swatistarster, Aug 1, 2012 IP
  8. ryogi

    ryogi Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I can help you clean up this mess and set up things straight. If you are willing to shell out some $ for the efforts, then PM me. It will take few hours to do the job.
     
    ryogi, Aug 4, 2012 IP
  9. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #9
    This part:
    $_SESSION['location']
    in the query, is a real head scratcher... are you saying you have a separate mysql table for EVERY option in that select? Do you have the PHP code that actually creates these tables? All... 35 of them?!? (If not, well there's your problem, though I suspect this should be using ONE table, not 35)

    I still can't figure out why it has a redirect for nothing, or even what this is supposed to... Whoever did that PHP for you is either unaware of require and/or include, or has no business writing php/sql code.

    Though if all you did was the markup and CSS, STOP inlining your style in the code, STOP using presentational classnames like 'blue' and 'magenta' (at that point you might as well go back to using HTML 3.2 1998 style), EVERY content tag is a child of body, so STOP saying BODY before them, and investigate how to build a proper form using tags like FIELDSET, LEGEND and LABEL. You don't just shove INPUT's and plaintext in there any old way. When you have a perfectly good class on a DIV, an H2 inside it shouldn't need a class...

    I'll see if I can take a stab at sorting out what this is SUPPOSED to do, but really... Whatever that is, I think it's going about it all wrong. The PHP isn't even proper, with typo's, omitted parenthesis, extra parenthesis, poor formatting...
     
    Last edited: Aug 5, 2012
    deathshadow, Aug 5, 2012 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #10
    No... more I look at it, the more I realize that we're either still missing a lot of code, or location.php is gibberish. I'm not sure what it's supposed to do, but what it does is... well... broken. Makes no sense at ALL.

    You say you didn't write the PHP part, when that's really who I'd have the questions for... why is it using so many tables, why is it trying to echo a _result set (which would just output the word "array" over and over), why is it using manual indexing with a for/next loop to do foreach's job... Why the stupid javascript redirect instead of just doing a include? why does it keep dropping in and out of PHP for no good reason? Why is it using the deprecated, insecure and soon to have support dropped mysql_ functions instead of PDO or mysqli?

    Without those answers, we really can't help you.
     
    Last edited: Aug 5, 2012
    deathshadow, Aug 5, 2012 IP