Skip to main content
Inspiring
March 29, 2012
Answered

Member Update Always Calls Blank Record to Edit

  • March 29, 2012
  • 1 reply
  • 973 views

I'm definitely a noob at PHP/MySQL.  I've been buying and reading books, etc. but I can't seem to get the memberUpdate form to return anything except a blank record when selected from a dropdown link after the member logs-in.  I've followed the instructions in DW5.5 The Missing Manual a dozen times.  Even though I believe I'm supposed to filter for a Form variable, I've played with Recordset filter until I'm blue in the face; trying URL param, Form variable and Server variable - all of which test just fine when I click the TEST button and enter a test value, but when I run it from the home page, through the log-in (on the homepage) to the Edit Profile dropdown link, it always shows blank fields, rather than that of the logged-in member.  Oh, I am using the member's email as the primary key in the database.  Please and thank you for any help you can be.  Here's the DW-generated PHP code from the memberUpdate file:

<?php require_once('../Connections/iama_test.php'); ?>
<?php
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 member SET loginTime=%s, createDate=%s, password=%s, lastName=%s, firstName=%s, organization=%s, address1=%s, address2=%s, city=%s, `state`=%s, zipcode=%s, renewDate=%s, memberType=%s, phone1=%s, phone2=%s, phone3=%s, email2=%s WHERE emailLogin=%s",
                       GetSQLValueString($_POST['loginTime'], "date"),
                       GetSQLValueString($_POST['createDate'], "date"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['lastName'], "text"),
                       GetSQLValueString($_POST['firstName'], "text"),
                       GetSQLValueString($_POST['organization'], "text"),
                       GetSQLValueString($_POST['address1'], "text"),
                       GetSQLValueString($_POST['address2'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['zipcode'], "text"),
                       GetSQLValueString($_POST['renewDate'], "date"),
                       GetSQLValueString($_POST['memberType'], "text"),
                       GetSQLValueString($_POST['phone1'], "text"),
                       GetSQLValueString($_POST['phone2'], "text"),
                       GetSQLValueString($_POST['phone3'], "text"),
                       GetSQLValueString($_POST['email2'], "text"),
                       GetSQLValueString($_POST['emailLogin'], "text"));

  mysql_select_db($database_iama_test, $iama_test);
  $Result1 = mysql_query($updateSQL, $iama_test) or die(mysql_error());

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

$colname_Recordset1 = "-1";
if (isset($_POST['emailLogin'])) {
  $colname_Recordset1 = $_POST['emailLogin'];
}
mysql_select_db($database_iama_test, $iama_test);
$query_Recordset1 = sprintf("SELECT * FROM member WHERE emailLogin = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $iama_test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

This topic has been closed for replies.
Correct answer wizbard

Well, I found a post here by Andoyo Andoyo and it was just what I needed, so thanks, Andoyo.  It worked the first time!  Now I can go play with it and see where I went wrong in the other file.  BTW, here is the link to the page that worked for me...  http://forums.adobe.com/message/1071495#1071495

1 reply

wizbardAuthorCorrect answer
Inspiring
March 29, 2012

Well, I found a post here by Andoyo Andoyo and it was just what I needed, so thanks, Andoyo.  It worked the first time!  Now I can go play with it and see where I went wrong in the other file.  BTW, here is the link to the page that worked for me...  http://forums.adobe.com/message/1071495#1071495