Dreamweaver Design Problem with setting up detail, update record page. Yes, a beginner PHP!

I need to set up a simple admin. Seeing my data, sending to a detail page, make changes and submit to DB. I have the DB setup, and the pages talk to it just fine so I'm at least ready for some real assistance here.
As you can see, at www.plugasong.com/admin/detail.php I got the data to appear with a link from the username. To the next page, how do I get the selection to show up in the form. I created hidden fields for the fields I didn't want to show, but nothing appears.
I can provide login info if you'd like.
I know this is cake to most of you, and hopefully will be to me when you get me though it. Thanks
e!
LVL 1
edvinsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineNo oneCommented:
Hi edvinson,

On the detail page, you need to create a recordset that filters on the URL Parameter passed to it by the master page.

So from this link:

http://www.plugasong.com/admin/detail2.php?recordID=6

you tell DW to filter on column recordID (or whatever it is called) using url parameter recordID

Once that is set up, you can then assign the data to the form fields by clicking the little lightning bolt next to the value box in the Properties panel.
0
edvinsonAuthor Commented:
Sage , thanks for getting back to me. I did all the above. Didn't seem to work as you'll see:

www.plugasong.com/admin/detail.php

I did assign the data fields to the form but nothing appears. hmmm

want to look inside? I've set up a temporary password.
0
Jason C. LevineNo oneCommented:
No need for that.  Just post the source code of detail2.php
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

edvinsonAuthor Commented:
OK here goes.


<?php require_once('../Connections/PlugASong.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $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 zip=%s, `state`=%s, city=%s, address=%s, username=%s, password=%s WHERE ID=%s",
                       GetSQLValueString($_POST['zip'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['ID'], "int"));

  mysql_select_db($database_PlugASong, $PlugASong);
  $Result1 = mysql_query($updateSQL, $PlugASong) or die(mysql_error());

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

$colname_Recordset1 = "-1";
if (isset($_GET['ID'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['ID'] : addslashes($_GET['ID']);
}
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = sprintf("SELECT * FROM users WHERE ID = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
  <div align="center">
    <p>
      <input name="username" type="text" id="username" value="<?php echo $row_Recordset1['username']; ?>" />
    </p>
    <p>
      <input name="password" type="text" id="password" value="<?php echo $row_Recordset1['password']; ?>" />
    </p>
    <p>
      <input name="city" type="text" id="city" value="<?php echo $row_Recordset1['city']; ?>" />
                                                                          
</p>
    <p>
      <input type="submit" name="Submit" value="Submit" />
      <input name="state" type="hidden" id="state" value="<?php echo $row_Recordset1['state']; ?>" />
      <input name="address" type="hidden" id="address" value="<?php echo $row_Recordset1['address']; ?>" />
      <input name="ID" type="hidden" id="ID" value="<?php echo $row_Recordset1['ID']; ?>" />
      <input name="zip" type="hidden" id="zip" value="<?php echo $row_Recordset1['zip']; ?>" />
    </p>
  </div>
 
 
 
  <input type="hidden" name="MM_update" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset1);
?>
0
Jason C. LevineNo oneCommented:
This part is wrong:

$colname_Recordset1 = "-1";
if (isset($_GET['ID'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['ID'] : addslashes($_GET['ID']);
}

ID is the name of the column.  The URL parameter is recordID.

So set the recordset to use ID as the column to filter on and recordID as the URL parameter.
0
edvinsonAuthor Commented:
Jason, it appears to me that is what I've done in the requestor box: See screenshot: Not much luck yet.
screenshot.jpg
0
Jason C. LevineNo oneCommented:
Nope.

Filter: ID = URL Parameter recordID

Not ID = ID

The URL Parameter is whatever appears after the ? in the URL.  This is called the Query String or the $_GET array.

So for http://www.plugasong.com/admin/detail2.php?recordID=6

The query string is recordID=6.  You need to tell DW to use recordID as the URL parameter.  The code it will write will look like this:

$colname_Recordset1 = "-1";
if (isset($_GET['recordID'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}

0
edvinsonAuthor Commented:
Hmmm Jason, I told the selector box to Filter ID, URL parameter and I had to overwrite the word ID with "recordID" in order to get it to take it, but it did.

Aparently there is something else wrong, somewhere else, possible on the the detail.php page?
Source code now for detail2.php:

<?php require_once('../Connections/PlugASong.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $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;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $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 zip=%s, `state`=%s, city=%s, address=%s, username=%s, password=%s WHERE ID=%s",
                       GetSQLValueString($_POST['zip'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['ID'], "int"));

  mysql_select_db($database_PlugASong, $PlugASong);
  $Result1 = mysql_query($updateSQL, $PlugASong) or die(mysql_error());

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

$colname_Recordset1 = "-1";
if (isset($_GET['RecordID'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['RecordID'] : addslashes($_GET['RecordID']);
}
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = sprintf("SELECT * FROM users WHERE ID = %s ORDER BY ID ASC", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
  <div align="center">
    <p>
      <input name="username" type="text" id="username" value="<?php echo $row_Recordset1['username']; ?>" />
    </p>
    <p>
      <input name="password" type="text" id="password" value="<?php echo $row_Recordset1['password']; ?>" />
    </p>
    <p>
      <input name="city" type="text" id="city" value="<?php echo $row_Recordset1['city']; ?>" />
                                                                          
</p>
    <p>
      <input type="submit" name="Submit" value="Submit" />
      <input name="state" type="hidden" id="state" value="<?php echo $row_Recordset1['state']; ?>" />
      <input name="address" type="hidden" id="address" value="<?php echo $row_Recordset1['address']; ?>" />
      <input name="ID" type="hidden" id="ID" value="<?php echo $row_Recordset1['ID']; ?>" />
      <input name="zip" type="hidden" id="zip" value="<?php echo $row_Recordset1['zip']; ?>" />
    </p>
  </div>
 
 
 
  <input type="hidden" name="MM_update" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset1);

mysql_free_result($Recordset1);
?>
0
Jason C. LevineNo oneCommented:
Two things, one significant, one not.

Significant = PHP is case sensitive.  You used RecordID (capital R).  You need recordID (lowercase R).

Not = It sort of looks like things have gone wacky.  There is a fair amount of repeated code here, possibly due to your messing with the code, then reapplying a behavior.  Use this version of the page before correcting the error.
<?php require_once('../Connections/PlugASong.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $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 zip=%s, `state`=%s, city=%s, address=%s, username=%s, password=%s WHERE ID=%s",
                       GetSQLValueString($_POST['zip'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['city'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['ID'], "int"));
 
  mysql_select_db($database_PlugASong, $PlugASong);
  $Result1 = mysql_query($updateSQL, $PlugASong) or die(mysql_error());
 
  $updateGoTo = "updated.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
$colname_Recordset1 = "-1";
if (isset($_GET['RecordID'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['RecordID'] : addslashes($_GET['RecordID']);
}
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = sprintf("SELECT * FROM users WHERE ID = %s ORDER BY ID ASC", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
  <div align="center">
    <p>
      <input name="username" type="text" id="username" value="<?php echo $row_Recordset1['username']; ?>" />
    </p>
    <p>
      <input name="password" type="text" id="password" value="<?php echo $row_Recordset1['password']; ?>" />
    </p>
    <p>
      <input name="city" type="text" id="city" value="<?php echo $row_Recordset1['city']; ?>" />
                                                                          
</p>
    <p>
      <input type="submit" name="Submit" value="Submit" />
      <input name="state" type="hidden" id="state" value="<?php echo $row_Recordset1['state']; ?>" />
      <input name="address" type="hidden" id="address" value="<?php echo $row_Recordset1['address']; ?>" />
      <input name="ID" type="hidden" id="ID" value="<?php echo $row_Recordset1['ID']; ?>" />
      <input name="zip" type="hidden" id="zip" value="<?php echo $row_Recordset1['zip']; ?>" />
    </p>
  </div>
 
 
 
  <input type="hidden" name="MM_update" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edvinsonAuthor Commented:
YESSSSSSSSSSSSSSSSSSSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Touchdown!!! Good job Jason. I know it was probably way beneath your interests, capabilities and patience...but you have been a tremendous help!!

Thank you
e!
0
edvinsonAuthor Commented:
Jason is awesome and was patient with my amateur self! Thanks again,

e!
0
Jason C. LevineNo oneCommented:
>> I know it was probably way beneath your interests, capabilities and patience...but you have been a tremendous
>> help!! Thank you

Nah, not beneath any of those things, not even my dignity: ).  You are also a very minor part of EE history now...this answer pushes me over the 1,000,000 point mark for DW.

w00t!

Good luck and you're welcome.  Feel free to post a new question when you get stuck again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.