2013-04-05 115 views
-1

我無法爲我的生活讓我的PHP來更新我的數據庫。我已經得到它插入,但沒有更新。一直在這裏超過2小時。我只需要一雙清新的眼睛!如果有人能弄清楚這件事情,這將是一個巨大的幫助。我可能會犯一些小愚蠢的錯誤,但是哦。如果我遺漏了一些您想看到的內容,請告訴我。這就是它會走向,http://cbogausch.com/portal/無法從php更新MySQL

update.php

<?php 
    include("config/db.php"); 
    if (isset($_POST['submit'])) { 
$sql = "UPDATE `secure_login`.`users` SET `link1` = \'$_POST[input_link1]\', `link2` = \'$_POST[input_link2]\', `link3` = \'$_POST[input_link3]\', `link4` = \'$_POST[input_link4]\', `link5` = \'$_POST[input_link5]\', `link6` = \'$_POST[input_link6]\', `link7` = \'$_POST[input_link7]\', `link8` = \'$_POST[input_link8]\', `link9` = \'$_POST[input_link9]\', `link10` = \'$_POST[input_link10]\', `link11` = \'$_POST[input_link11]\', `link12` = \'$_POST[input_link12]\', `pic1` = \'$_POST[input_pic1]\', `pic2` = \'$_POST[input_pic2]\', `pic3` = \'$_POST[input_pic3]\', `pic4` = \'$_POST[input_pic4]\', `pic5` = \'$_POST[input_pic5]\', `pic6` = \'$_POST[input_pic6]\', `pic7` = \'$_POST[input_pic7]\', `pic8` = \'$_POST[input_pic8]\', `pic9` = \'$_POST[input_pic9]\', `pic10` = \'$_POST[input_pic10]\', `pic11` = \'$_POST[input_pic11]\', `pic12` = \'$_POST[input_pic12]\', WHERE `users`.`user_id` = 1;"; 

mysql_query($sql);// or die mysql_error(); 
    } 
    // class autoloader function, this includes all the classes that are needed by the script 
    // you can remove this stuff if you want to include your files manually 




    function autoload($class) 
    { 
     require('classes/' . $class . '.class.php'); 
    } 

    // automatically loads all needed classes, when they are needed 
    spl_autoload_register("autoload"); 


    //create a database connection 
    $db = new Database(); 

    // start this baby and give it the database connection 
    $login = new Login($db); 
    ?> 
    <?php include('views/header/header.php'); 
    ?> 
        <div style="position:absolute; top:0; right:5%; background-color:#fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25); width:450px; height:45px;"> 
          <div style="float:left; height:30px;"> 
            <img src="<?php echo "http://www.gravatar.com/avatar/" . md5(strtolower(trim($_SESSION['user_email']))) . "?d=mm&s=40"; ?>" style="width:30px; height:30px; border-radius:15px; border:8px solid #ccc;" />         
          </div>  
          <div style="float:left; height:30px; margin-left:10px; line-height:30px;"> 
           <div style="font-size:12px; font-weight:normal;">Hey, <?php echo $_SESSION['user_name']; ?> (<span style="font-size:12px; color:red;"><?php echo substr($_SESSION['user_email'], 0, 15); ?>...</span>). You're logged in. <a href="settings.php">(Settings!)</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout">(Logout)</a> </div> 
          </div> 
        </div> 
      </div> 
    <div style="position:absolute; top:60px; bottom:5%; left:5%; right:5%; background-color:#C0C0C0; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25); width:90%; height:100%; text-align:center;"> 
     <center> 
     <?php echo $_POST["input_link3"] ?> 
     <?php include('toggle.php'); ?> 
     </br> 
     </br> 
     <?php include('quote.php'); ?> 
     </br> 
     </br> 
    <form method="post" action="update.php"> 
    <div style="background-color:white"> 
    <table width=75%; border-color=red; style="border:2px solid black;max-width:100%; background-color:white; text-align:center;"> 
    <tr> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #1</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link1" size="40" size="40" value="<?php echo $_SESSION['link1']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic1" size="40" size="40" value="<?php echo $_SESSION['pic1']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #2</b> 
     </br> 
     Link URL: 
     <input id="input_link2" class="settings" type="text" name="input_link2" size="40" value="<?php echo $_SESSION['link2']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic2" class="settings" type="text" name="input_pic2" size="40" value="<?php echo $_SESSION['pic2']; ?>" /> 
    </td>   
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #3</b> 
     </br> 
     Link URL: 
     <input id="input_link3" class="settings" type="text" name="input_link3" size="40" value="<?php echo $_SESSION['link3']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic3" class="settings" type="text" name="input_pic3" size="40" value="<?php echo $_SESSION['pic3']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #4</b> 
     </br> 
     Link URL: 
     <input id="input_link4" class="settings" type="text" name="input_link4" size="40" value="<?php echo $_SESSION['link4']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic4" class="settings" type="text" name="input_pic4" size="40" value="<?php echo $_SESSION['pic4']; ?>" /> 
    </td> 
    </tr> 
    <tr> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #5</b> 
     </br> 
     Link URL: 
     <input id="input_link5" class="settings" type="text" name="input_link5" size="40" value="<?php echo $_SESSION['link5']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic5" class="settings" type="text" name="input_pic5" size="40" value="<?php echo $_SESSION['pic5']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #6</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link6" size="40" size="40" value="<?php echo $_SESSION['link6']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic6" size="40" size="40" value="<?php echo $_SESSION['pic6']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #7</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link7" size="40" size="40" value="<?php echo $_SESSION['link7']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic7" size="40" size="40" value="<?php echo $_SESSION['pic7']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #8</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link8" size="40" size="40" value="<?php echo $_SESSION['link8']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic8" size="40" size="40" value="<?php echo $_SESSION['pic8']; ?>" /> 
    </td> 
    </tr> 
    <tr> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #9</b> 
     </br> 
     Link URL: 
     <input id="input_link5" class="settings" type="text" name="input_link9" size="40" value="<?php echo $_SESSION['link9']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic5" class="settings" type="text" name="input_pic9" size="40" value="<?php echo $_SESSION['pic9']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #10</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link10" size="40" size="40" value="<?php echo $_SESSION['link10']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic10" size="40" size="40" value="<?php echo $_SESSION['pic10']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #11</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link11" size="40" size="40" value="<?php echo $_SESSION['link11']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic11" size="40" size="40" value="<?php echo $_SESSION['pic11']; ?>" /> 
    </td> 
    <td style="border:2px solid black;max-width:100%;"> 
     <b>Link #12</b> 
     </br> 
     Link URL: 
     <input id="input_link1" class="settings" type="text" name="input_link12" size="40" size="40" value="<?php echo $_SESSION['link12']; ?>" /> 
     </br> 
     Link Image: 
     <input id="input_pic1" class="settings" type="text" name="input_pic12" size="40" size="40" value="<?php echo $_SESSION['pic12']; ?>" /> 
    </td> 
    </tr> 
    <tr> 
    <td></td> 
    <td></td> 
    <td> 
     <input type="submit"> 
    </td> 
    <td> 
     <a href="index.php">Back to Main Page</a> 
    </td> 
    </tr> 
    </table> 
    </div> 
    </form> 
    </center> 
    </div> 

    <?php include('views/footer/footer.php'); ?> 

,這裏是我的數據庫連接

<?php 
define("DB_HOST", "cboga*****.com"); 
define("DB_NAME", "secure_login"); 
define("DB_USER", "******"); 
define("DB_PASS", "******"); 
?> 
+0

好混亂的代碼;( – 2013-04-05 07:11:41

+0

經過這樣一個好萊塢風格的場景創作後,我期待一個問題到底:)即錯誤是什麼? – 2013-04-05 07:11:55

+2

那麼你很容易受到這個代碼的黑客攻擊。更好的是它並沒有起到作用。 – 2013-04-05 07:12:54

回答

0

現在嘗試

<?php 
include("config/db.php"); 
if (isset($_POST['submit'])) { 
$sql = "UPDATE `secure_login`.`users` SET `link1` = \'$_POST[input_link1]\', `link2` = \'$_POST[input_link2]\', `link3` = \'$_POST[input_link3]\', `link4` = \'$_POST[input_link4]\', `link5` = \'$_POST[input_link5]\', `link6` = \'$_POST[input_link6]\', `link7` = \'$_POST[input_link7]\', `link8` = \'$_POST[input_link8]\', `link9` = \'$_POST[input_link9]\', `link10` = \'$_POST[input_link10]\', `link11` = \'$_POST[input_link11]\', `link12` = \'$_POST[input_link12]\', `pic1` = \'$_POST[input_pic1]\', `pic2` = \'$_POST[input_pic2]\', `pic3` = \'$_POST[input_pic3]\', `pic4` = \'$_POST[input_pic4]\', `pic5` = \'$_POST[input_pic5]\', `pic6` = \'$_POST[input_pic6]\', `pic7` = \'$_POST[input_pic7]\', `pic8` = \'$_POST[input_pic8]\', `pic9` = \'$_POST[input_pic9]\', `pic10` = \'$_POST[input_pic10]\', `pic11` = \'$_POST[input_pic11]\', `pic12` = \'$_POST[input_pic12]\', WHERE `users`.`user_id` = 1;"; 

mysql_query($sql);// or die mysql_error(); 
    } 
// class autoloader function, this includes all the classes that are needed by the script 
// you can remove this stuff if you want to include your files manually 




function autoload($class) 
{ 
    require('classes/' . $class . '.class.php'); 
} 

// automatically loads all needed classes, when they are needed 
spl_autoload_register("autoload"); 


//create a database connection 
$db = new Database(); 

// start this baby and give it the database connection 
$login = new Login($db); 
?> 
<?php include('views/header/header.php'); 
?> 
       <div style="position:absolute; top:0; right:5%; background-color:#fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25); width:450px; height:45px;"> 
         <div style="float:left; height:30px;"> 
           <img src="<?php echo "http://www.gravatar.com/avatar/" . md5(strtolower(trim($_SESSION['user_email']))) . "?d=mm&s=40"; ?>" style="width:30px; height:30px; border-radius:15px; border:8px solid #ccc;" />         
         </div>  
         <div style="float:left; height:30px; margin-left:10px; line-height:30px;"> 
          <div style="font-size:12px; font-weight:normal;">Hey, <?php echo $_SESSION['user_name']; ?> (<span style="font-size:12px; color:red;"><?php echo substr($_SESSION['user_email'], 0, 15); ?>...</span>). You're logged in. <a href="settings.php">(Settings!)</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout">(Logout)</a> </div> 
         </div> 
       </div> 
     </div> 
<div style="position:absolute; top:60px; bottom:5%; left:5%; right:5%; background-color:#C0C0C0; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25); width:90%; height:100%; text-align:center;"> 
    <center> 
    <?php echo $_POST["input_link3"] ?> 
    <?php include('toggle.php'); ?> 
    </br> 
    </br> 
    <?php include('quote.php'); ?> 
    </br> 
    </br> 
<form method="post" action="insert.php"> 
<div style="background-color:white"> 
<table width=75%; border-color=red; style="border:2px solid black;max-width:100%; background-color:white; text-align:center;"> 
<tr> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #1</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link1" size="40" size="40" value="<?php echo $_SESSION['link1']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic1" size="40" size="40" value="<?php echo $_SESSION['pic1']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #2</b> 
    </br> 
    Link URL: 
    <input id="input_link2" class="settings" type="text" name="input_link2" size="40" value="<?php echo $_SESSION['link2']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic2" class="settings" type="text" name="input_pic2" size="40" value="<?php echo $_SESSION['pic2']; ?>" /> 
</td>   
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #3</b> 
    </br> 
    Link URL: 
    <input id="input_link3" class="settings" type="text" name="input_link3" size="40" value="<?php echo $_SESSION['link3']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic3" class="settings" type="text" name="input_pic3" size="40" value="<?php echo $_SESSION['pic3']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #4</b> 
    </br> 
    Link URL: 
    <input id="input_link4" class="settings" type="text" name="input_link4" size="40" value="<?php echo $_SESSION['link4']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic4" class="settings" type="text" name="input_pic4" size="40" value="<?php echo $_SESSION['pic4']; ?>" /> 
</td> 
</tr> 
<tr> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #5</b> 
    </br> 
    Link URL: 
    <input id="input_link5" class="settings" type="text" name="input_link5" size="40" value="<?php echo $_SESSION['link5']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic5" class="settings" type="text" name="input_pic5" size="40" value="<?php echo $_SESSION['pic5']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #6</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link6" size="40" size="40" value="<?php echo $_SESSION['link6']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic6" size="40" size="40" value="<?php echo $_SESSION['pic6']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #7</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link7" size="40" size="40" value="<?php echo $_SESSION['link7']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic7" size="40" size="40" value="<?php echo $_SESSION['pic7']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #8</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link8" size="40" size="40" value="<?php echo $_SESSION['link8']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic8" size="40" size="40" value="<?php echo $_SESSION['pic8']; ?>" /> 
</td> 
</tr> 
<tr> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #9</b> 
    </br> 
    Link URL: 
    <input id="input_link5" class="settings" type="text" name="input_link9" size="40" value="<?php echo $_SESSION['link9']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic5" class="settings" type="text" name="input_pic9" size="40" value="<?php echo $_SESSION['pic9']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #10</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link10" size="40" size="40" value="<?php echo $_SESSION['link10']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic10" size="40" size="40" value="<?php echo $_SESSION['pic10']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #11</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link11" size="40" size="40" value="<?php echo $_SESSION['link11']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic11" size="40" size="40" value="<?php echo $_SESSION['pic11']; ?>" /> 
</td> 
<td style="border:2px solid black;max-width:100%;"> 
    <b>Link #12</b> 
    </br> 
    Link URL: 
    <input id="input_link1" class="settings" type="text" name="input_link12" size="40" size="40" value="<?php echo $_SESSION['link12']; ?>" /> 
    </br> 
    Link Image: 
    <input id="input_pic1" class="settings" type="text" name="input_pic12" size="40" size="40" value="<?php echo $_SESSION['pic12']; ?>" /> 
</td> 
</tr> 
<tr> 
<td></td> 
<td></td> 
<td> 
    <input type="submit"> 
</td> 
<td> 
    <a href="index.php">Back to Main Page</a> 
</td> 
</tr> 
</table> 
</div> 
</form> 
</center> 
</div> 

<?php include('views/footer/footer.php'); ?> 
+0

工程,但仍然在黑客之下。 – 2013-04-05 07:16:52

+1

你應該至少提到你改變了什麼:) – KyleK 2013-04-05 07:17:37

+0

對不起;)。他之前沒有執行查詢。 – 2013-04-05 07:18:40

1

你應該實際上執行查詢mysql_query()並且請粘貼LESS代碼,限制在您確定的位置 問題是。我明白,你不確定我們願意幫助的確切位置,但拜託,並不意味着你要退後一步。噢,並請收拾你的代碼...