1

我试图使用 Dreamweaver 更新记录来创建一个页面,用户可以在其中编辑他们的帐户,但是一旦我提交,数据库中的任何内容都不会更新。有什么建议么?代码如下。请帮忙..

<?php require_once('../../Connections/mySQL.php'); ?>
<?php

session_start();

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE Users SET first_name=%s, last_name=%s, mdcps_idnumber=%s, phone=%s, Username=%s, Password=%s, email=%s, class_code=%s WHERE id=%s",
                       GetSQLValueString($_POST['first_name'], "text"),
                       GetSQLValueString($_POST['last_name'], "text"),
                       GetSQLValueString($_POST['mdcps_idnumber'], "text"),
                       GetSQLValueString($_POST['phone'], "text"),
                       GetSQLValueString($_POST['Username'], "text"),
                       GetSQLValueString($_POST['Password'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['class_code'], "int"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_mySQL, $mySQL);
  $Result1 = mysql_query($updateSQL, $mySQL) or die(mysql_error());

  $updateGoTo = "../pro.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['Username'])) {
  $colname_Recordset1 = $_GET['Username'];
}
mysql_select_db($database_mySQL, $mySQL);
$query_Recordset1 = sprintf("SELECT * FROM Users WHERE Username = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $mySQL) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

//STEP 1 Connect To Database
$connect = mysql_connect("Localhost","mlec2013_danny","8764963d");
if (!$connect)
{
die("MySQL could not connect!");
}

$DB = mysql_select_db('mlec2013_database');

if(!$DB)
{
die("MySQL could not select Database!");
}

//STEP 2 Declare Variables

$Name = $_POST['username'];
$Pass = $_POST['password'];
$Query = mysql_query("SELECT * FROM Users WHERE Username='$Name' AND Password='$Pass'");
$NumRows = mysql_num_rows($Query);
$_SESSION['username'] = $Name;
$_SESSION['password'] = $Pass;

//STEP 3 Check to See If User Entered All Of The Information

if(empty($_SESSION['username']) || empty($_SESSION['password']))
{
die("Go back and login before you visit this page!");
}

if($Name && $Pass == "")
{
die("Please enter in a name and password!");
}

if($Name == "")
{
die("Please enter your name!" . "</br>");
}

if($Pass == "")
{
die("Please enter a password!");
echo "</br>";
}

//STEP 4 Check Username And Password With The MySQL Database

if($NumRows != 0)
{
while($Row = mysql_fetch_assoc($Query))
{
$Database_Name = $Row['username'];
$Database_Pass = $Row['password'];
}
}
else
{
die("Incorrect Username or Password!");
}


//end of PHP scripting. Information displayed below is in the form of HTML, CSS, or Javascript.

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title>Beautiful advanced jQuery background image slideshow</title>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="../../js/script.js"></script>
<script src="../../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<style type="text/css">
<!--
#apDiv1 {
    position:absolute;
    width:200px;
    height:115px;
    z-index:1001;
    left: -29px;
    top: 642px;
}
#loginregis {
    position: absolute;
    left: 997px;
    top: 4px;
    width: 399px;
    height: 55px;
    z-index: 1001;
    border: 0;
}
.indentation {
    text-indent: 15px;
}
#content table tr td p .indentation {
    font-style: italic;
}
-->
</style>
<link href="../../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="top" id="header">
    <!-- jQuery handles to place the header background images -->
  <div id="headerimgs">
        <div id="headerimg1" class="headerimg"></div>
        <div id="headerimg2" class="headerimg"></div>
    </div>
    <!-- Top navigation on top of the images -->
    <div id="nav-outer">
      <div id="navigation"></div>
      <div id="searchdiv">
        <form action="" method="get" enctype="application/x-www-form-urlencoded"
            name="search">
          <input name="search" size="25" maxlength="50" type="text">
          <label for="submit2"></label>
          <input name="submit" id="submit2" value="Submit"
              type="submit">
        </form>
      </div>
      <div> </div>
      <div>
        <ul id="MenuBar1" class="MenuBarVertical">
          <li><a href="../../index.html" class="MenuBarItemSubmenu">Home</a>
            <ul>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/lr/login.php">Login</a></li>
            </ul>
          </li>
          <li><a href="../../about.html" class="MenuBarItemSubmenu">About Us</a>
            <ul>
              <li><a href="../../about.html">About Us</a></li>
            </ul>
          </li>
          <li><a href="../../news.html" class="MenuBarItemSubmenu">News</a>
            <ul>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/news/archives.html">Archived Issues</a></li>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/news/nov12">Nov. 2012</a></li>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/news/dec12">Dec. 2012</a></li>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/news/jan13">Jan. 2013</a></li>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/news/feb13">Feb. 2013</a></li>
              <li><a href="file:///C|/Users/Danny/Desktop/ebusiness/news/mar13">Mar. 2013</a></li>
            </ul>
          </li>
          <li><a href="../../programmes.html" class="MenuBarItemSubmenu">Academy Resources</a>
            <ul>
              <li><a href="#">Academies</a></li>
              <li><a href="#">C.A.P. Corner</a></li>
              <li><a href="#">Capstone Resources</a></li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">Student Interests</a>
            <ul>
              <li><a href="#">Clubs/ Organizations</a></li>
              <li><a href="#">Sports</a></li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">Events</a>
            <ul>
              <li><a href="#">Requirements Checker</a></li>
              <li><a href="#">Graduation</a></li>
              <li><a href="#">Other Events</a></li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">M-DCPS</a>
            <ul>
              <li><a href="http://www.dadeschools.net">M-DCPS</a></li>
              <li><a href="http://mlec.dadeschools.net">MLEC School Site</a></li>
              <li><a href="http://www.flvs.net">FLVS</a></li>
            </ul>
          </li>
          <li><a href="#" class="MenuBarItemSubmenu">Contact Us</a>
            <ul>
              <li><a href="#">Contact S.G.A.</a></li>
              <li><a href="#">Contact MLEC</a></li>
            </ul>
          </li>
        </ul>
</div>
      <div> </div>
  </div>
    <!-- Slideshow controls -->
    <!-- jQuery handles for the text displayed on top of the images -->
</div>
<div id="content" style="width:1346px align:center">
  <div id="content2"></div>
  <table width="100" border="0" cellspacing="0" cellpadding="100">
  <tr>
    <th scope="row"><div align="center" class="sidebarbackground" id="sidebar">
      <h1>Log-in</h1>
      <h2>Hello, <? echo $_SESSION['username'] ?> </h2>
      <blockquote>
        <p><a href="account.php">Account</a></p>
        <p>Settings</p>
        <p>Messages</p>
        <p>Log-off</p>
      </blockquote>
      <h2>S.G.A.</h2>
      <p>About S.G.A.</p>
      <p>MLEC S.G.A. Team</p>
      <p>Join S.G.A.</p>
      <p>Events</p>
<h2>ASGP</h2>
<p>About ASGP (Accel. <br>
  Student Gov. Protocal)</p>
<p>Event Tickets</p>
<p>Help</p>
<p>FAQs</p>
<p>&nbsp;</p>
      <h5>&nbsp;</h5>
    </div></th>
    <td width="1096"><p><img src="../../images/titles/welcome.png" width="104" height="27">
    <br>
      </p>
      <p>&nbsp;</p>
      <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
        <table align="center">
          <tr valign="baseline">
            <td nowrap align="right">First_name:</td>
            <td><input type="text" name="first_name" value="<?php echo htmlentities($row_Recordset1['first_name'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Last_name:</td>
            <td><input type="text" name="last_name" value="<?php echo htmlentities($row_Recordset1['last_name'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Mdcps_idnumber:</td>
            <td><input type="text" name="mdcps_idnumber" value="<?php echo htmlentities($row_Recordset1['mdcps_idnumber'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Phone:</td>
            <td><input type="text" name="phone" value="<?php echo htmlentities($row_Recordset1['phone'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Username:</td>
            <td><input type="text" name="Username" value="<?php echo htmlentities($row_Recordset1['Username'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Password:</td>
            <td><input type="text" name="Password" value="<?php echo htmlentities($row_Recordset1['Password'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Email:</td>
            <td><input type="text" name="email" value="<?php echo htmlentities($row_Recordset1['email'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">Class_code:</td>
            <td><input type="text" name="class_code" value="<?php echo htmlentities($row_Recordset1['class_code'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">&nbsp;</td>
            <td><input type="submit" value="Update record"></td>
          </tr>
        </table>
        <input type="hidden" name="MM_update" value="form1">
        <input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>">
      </form>
      <p>&nbsp;</p>
<p><br>
        This is your personal profile page for the Accelerated Student Government Protocal system! This is the system to be used for the purchase of S.G.A. sponsored events, pay for class dues, and much more. If you need help getting around the system visit the help page.</p>
      <p>What do you wish to do?</p>
      <table border="0" id="menuu">
        <tr>
          <th>Buy an event ticket</th>
          <th>Make a payment</th>
        </tr>
        <tr>
          <th>Edit the your settings</th>
          <th>Apply to S.G.A.</th>
        </tr>
        <tr>
          <th>View your account information</th>
          <th>Read your messages</th>
        </tr>
      </table>
      <p>&nbsp;</p>
      <p><br>
</p>
      <p><br>
        If you need to reset your password for any reason please <a href="../reset.html">click here</a>. For any other question regarding the ASGP please email us at <a href="mailto:asgp@mlec2013.x10.mx">asgp@mlec2013.x10.mx</a>.<br>
        <br>
  </p>
      <p>&nbsp;</p>
      <p>&nbsp; </p>
      <p></p>
      <p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
      <p>&nbsp;</p>
    </td>
  </tr>
</table>
</div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
4

0 回答 0