Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help passing info from variable to mysql login from a text feild

    The problem am having is when i put in the SQL login information form the forum it does not load in to my 2 SQL viewers.

    Would I need to make a session or can this be achieved without one? I’m out of ideas; I have tried to pass the variable etc. I normally do java desktop application trying to get in to web design etc.

    Here's my code:
    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Team Manager</title>
    <link href="TeamManger.css" rel="stylesheet" type="text/css">
    <link href="index.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="fancybox/jquery.easing-1.3.pack.js"></script>
    <link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.0.css" type="text/css">
    <script type="text/javascript" src="fancybox/jquery.fancybox-1.3.0.pack.js"></script>
    <script type="text/javascript" src="fancybox/jquery.mousewheel-3.0.2.pack.js"></script>
    <script type="text/javascript" src="wwb9.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function()
    {
       $.fn.alternateRowColors = function()
       {
          $('tbody tr:odd', this).removeClass('even').addClass('odd');
          $('tbody tr:even', this).removeClass('odd').addClass('even');
          return this;
       };
       $('table.sortable').each(function()
       {
          var $dataviewer = $(this);
          $dataviewer.alternateRowColors();
          $('th', $dataviewer).each(function(column)
          {
             var $header = $(this);
             var findSortKey;
             findSortKey = function($cell)
             {
                return $cell.find('.sort-key').text().toUpperCase() + ' ' + $cell.text().toUpperCase();
             };
             if (findSortKey)
             {
                $header.addClass('clickable').hover(function()
                {
                   $header.addClass('hover');
                }, function()
                {
                   $header.removeClass('hover');
                }).click(function()
                {
                   var sortDirection = 1;
                   if ($header.is('.sorted-asc'))
                   {
                      sortDirection = -1;
                   }
                   var rows = $dataviewer.find('tbody > tr').get();
                   $.each(rows, function(index, row)
                   {
                      var $cell = $(row).children('td').eq(column);
                      row.sortKey = findSortKey($cell);
                   });
                   rows.sort(function(a, b)
                   {
                      if (a.sortKey < b.sortKey) return -sortDirection;
                      if (a.sortKey > b.sortKey) return sortDirection;
                      return 0;
                   });
                   $.each(rows, function(index, row)
                   {
                      $dataviewer.children('tbody').append(row);
                      row.sortKey = null;
                   });
                   $dataviewer.find('th').removeClass('sorted-asc').removeClass('sorted-desc');
                   if (sortDirection == 1)
                   {
                      $header.addClass('sorted-asc');
                   }
                   else
                   {
                      $header.addClass('sorted-desc');
                   }
                   $dataviewer.find('td').removeClass('sorted').filter(':nth-child(' + (column + 1) + ')').addClass('sorted');
                   $dataviewer.alternateRowColors();
                });
             }
          });
       });
       $.fn.alternateRowColors = function()
       {
          $('tbody tr:odd', this).removeClass('even').addClass('odd');
          $('tbody tr:even', this).removeClass('odd').addClass('even');
          return this;
       };
       $('table.sortable').each(function()
       {
          var $dataviewer = $(this);
          $dataviewer.alternateRowColors();
          $('th', $dataviewer).each(function(column)
          {
             var $header = $(this);
             var findSortKey;
             findSortKey = function($cell)
             {
                return $cell.find('.sort-key').text().toUpperCase() + ' ' + $cell.text().toUpperCase();
             };
             if (findSortKey)
             {
                $header.addClass('clickable').hover(function()
                {
                   $header.addClass('hover');
                }, function()
                {
                   $header.removeClass('hover');
                }).click(function()
                {
                   var sortDirection = 1;
                   if ($header.is('.sorted-asc'))
                   {
                      sortDirection = -1;
                   }
                   var rows = $dataviewer.find('tbody > tr').get();
                   $.each(rows, function(index, row)
                   {
                      var $cell = $(row).children('td').eq(column);
                      row.sortKey = findSortKey($cell);
                   });
                   rows.sort(function(a, b)
                   {
                      if (a.sortKey < b.sortKey) return -sortDirection;
                      if (a.sortKey > b.sortKey) return sortDirection;
                      return 0;
                   });
                   $.each(rows, function(index, row)
                   {
                      $dataviewer.children('tbody').append(row);
                      row.sortKey = null;
                   });
                   $dataviewer.find('th').removeClass('sorted-asc').removeClass('sorted-desc');
                   if (sortDirection == 1)
                   {
                      $header.addClass('sorted-asc');
                   }
                   else
                   {
                      $header.addClass('sorted-desc');
                   }
                   $dataviewer.find('td').removeClass('sorted').filter(':nth-child(' + (column + 1) + ')').addClass('sorted');
                   $dataviewer.alternateRowColors();
                });
             }
          });
       });
    });
    </script>
    </head>
    <body>
    <?php
    if(isset($_POST['add']))
    {
    $dbhost = '';
    $dbuser = '';
    $dbpass = '';
    
    if(! get_magic_quotes_gpc() )
    {
       $dbhost = addslashes ($_POST['dbhost']);
       $dbpass = addslashes ($_POST['dbpass']);
       $dbuser = addslashes ($_POST['dbuser']);
    }
    else
    {
       $dbhost = $_POST['dbhost'];
       $dbuser = $_POST['dbuser'];
       $dbpass = $_POST['dbpass'];
    }
    
    }
    
    ?>
       <div id="space"><br></div>
       <div id="container">
          <div id="playerdataviewer" style="position:absolute;overflow:auto;left:0px;top:180px;width:450px;height:450px;z-index:9">
    <?php
    $dbhost = $mysql_host1 ;
    $dbuser = $mysql_user1;
    $dbpass = $mysql_password1;
    $mysql_database1 = 'teammanger';
    $mysql_table1 = 'teamdb';
    $db = mysql_connect($mysql_host1, $mysql_user1, $mysql_password1);
    mysql_select_db($mysql_database1, $db1);
    $sql1 = "SELECT * FROM ".$mysql_table;
    $result = mysql_query($sql1, $db1);
    ?>
             <table cellpadding="0" cellspacing="0" width="100%" class="sortable paginated">
                <thead>
                   <tr>
    <?php
    $fields_num = mysql_num_fields($result);
    for ($i=0; $i<$fields_num; $i++)
    {
       $field = mysql_fetch_field($result);
       echo "      <th>" . $field->name . "</th>\n";
    }
    ?>
                   </tr>
                </thead>
                <tbody>
    <?php
    while ($row = mysql_fetch_row($result))
    {
       echo "   <tr>\n";
       foreach ($row as $cell)
       {
          echo "      <td>" . $cell . "</td>\n";
       }
       echo "   </tr>\n";
    }
    ?>
                </tbody>
             </table>
          </div>
          <div id="teamdataviewer" style="position:absolute;overflow:auto;left:510px;top:180px;width:440px;height:450px;z-index:10">
    <?php
    $dbhost = $mysql_host ;
    $dbuser = $mysql_user;
    $dbpass = $mysql_password;
    
    
    
    $mysql_database = 'teammanger';
    $mysql_table = 'teamdb';
    $db = mysql_connect($mysql_host, $mysql_user, $mysql_password);
    mysql_select_db($mysql_database, $db);
    $sql = "SELECT * FROM ".$mysql_table;
    $result = mysql_query($sql, $db);
    ?>
             <table cellpadding="0" cellspacing="0" width="100%" class="sortable paginated">
                <thead>
                   <tr>
    <?php
    $fields_num = mysql_num_fields($result);
    for ($i=0; $i<$fields_num; $i++)
    {
       $field = mysql_fetch_field($result);
       echo "      <th>" . $field->name . "</th>\n";
    }
    ?>
                   </tr>
                </thead>
                <tbody>
    <?php
    while ($row = mysql_fetch_row($result))
    {
       echo "   <tr>\n";
       foreach ($row as $cell)
       {
          echo "      <td>" . $cell . "</td>\n";
       }
       echo "   </tr>\n";
    }
    ?>
                </tbody>
             </table>
          </div>
          <img src="images/img0005.jpg" id="Banner1" alt="Team Manager" style="position:absolute;left:350px;top:0px;width:500px;height:60px;border-width:0;z-index:11;">
          <a href="javascript:displaylightbox('./Add/AddPlayers.php',{})" target="_self"><img src="images/img0010.jpg" id="Banner2" alt="Add Players" style="position:absolute;left:430px;top:120px;width:140px;height:20px;border-width:0;z-index:12;"></a>
          <a href="javascript:displaylightbox('./Remove/RemovePlayers.php',{})" target="_self"><img src="images/img0011.jpg" id="Banner3" alt="Remove Players" style="position:absolute;left:430px;top:160px;width:140px;height:20px;border-width:0;z-index:13;"></a>
          <a href="javascript:displaylightbox('./Add/AddTeam.php',{})" target="_self"><img src="images/img0012.jpg" id="Banner4" alt="Add Teams" style="position:absolute;left:640px;top:120px;width:130px;height:20px;border-width:0;z-index:14;"></a>
          <a href="javascript:displaylightbox('./Remove/RemoveTeam.php',{})" target="_self"><img src="images/img0013.jpg" id="Banner5" alt="Remove Teams" style="position:absolute;left:640px;top:160px;width:130px;height:20px;border-width:0;z-index:15;"></a>
          <a href="javascript:displaylightbox('./TeamChange.php',{})" target="_self"><img src="images/img0016.jpg" id="Banner6" alt="Change Team" style="position:absolute;left:530px;top:80px;width:130px;height:20px;border-width:0;z-index:16;"></a>
    
          <div id="wb_Form1" style="position:absolute;left:0px;top:0px;width:306px;height:180px;z-index:17;">
             <form name="Form1" method="post" action="<?php $_PHP_SELF ?>" id="Form1">
    
                <div id="wb_Text1" style="position:absolute;left:10px;top:15px;width:66px;height:16px;z-index:0;text-align:left;">
                   <span style="color:#000000;font-family:arial;font-size:13px;">Host:</span></div>
                <!Host  >
                <input type="text" id="dbhost" style="position:absolute;left:86px;top:15px;width:198px;height:23px;line-height:23px;z-index:1;" name="dbhost" value="">
                <div id="wb_Text2" style="position:absolute;left:10px;top:45px;width:66px;height:16px;z-index:2;text-align:left;">
                <! User >
                   <span style="color:#000000;font-family:arial;font-size:13px;">User:</span></div>
                <input type="text" id="dbuser" style="position:absolute;left:86px;top:45px;width:198px;height:23px;line-height:23px;z-index:3;" name="dbuser" value="">
                <div id="wb_Text3" style="position:absolute;left:10px;top:75px;width:66px;height:16px;z-index:4;text-align:left;">
                <! Password >
                   <span style="color:#000000;font-family:arial;font-size:13px;">Password:</span></div>
                <input type="password" id="dbpass" style="position:absolute;left:86px;top:75px;width:198px;height:23px;line-height:23px;z-index:5;" name="dbpass" value="">
                <div id="wb_Text4" style="position:absolute;left:10px;top:105px;width:66px;height:16px;z-index:6;text-align:left;">
                <! DataBase >
                   <span style="color:#000000;font-family:arial;font-size:13px;">DataBase:</span></div>
                <input type="text" id="Editbox4" style="position:absolute;left:86px;top:105px;width:198px;height:23px;line-height:23px;z-index:7;" name="Editbox4" value="">
                <input type="submit" id="Button1" name="" value="Submit" style="position:absolute;left:86px;top:135px;width:96px;height:25px;z-index:8;">
             </form>
          </div>
       </div>
    </body>
    </html>
    Here is a live example: Ilmo.servegame.com

    Im trying to get the info from the text boxes send that to my sql thin have the sql viewers display the data.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,180
    Thanks
    23
    Thanked 602 Times in 601 Posts
    Here's a start for you. This may occur in a lot of other places.
    You have this:
    Code:
    <?php
    $dbhost = $mysql_host1 ;
    $dbuser = $mysql_user1;
    $dbpass = $mysql_password1;
    $mysql_database1 = 'teammanger';
    $mysql_table1 = 'teamdb';
    $db = mysql_connect($mysql_host1, $mysql_user1, $mysql_password1);
    mysql_select_db($mysql_database1, $db1);
    $sql1 = "SELECT * FROM ".$mysql_table;
    $result = mysql_query($sql1, $db1);
    ?>
    $mysql_host1 only appears at these two places. It is not defined. Maybe you meant
    Code:
    $mysql_host1 =$dbhost;
    Same goes for $dbuser = $mysql_user1; and $dbpass = $mysql_password1;

    $db1 is another variable that is not defined. Maybe you meant $db, and that is not really needed.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Tags for this Thread

    Posting Permissions

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