Get record # from end of url error

7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 3, 2015   (RSS)

By nmsinc - June 3, 2015

I have the following code below. When I submit the selected 'num' will not execute through to the URL - any ideas what I'm doing wrong here?

Thanks - nmsinc

<select name="num">
<?php foreach ($code_typesRecords as $type): ?>
<?php if ($CURRENT_USER['isAdmin']): ?>
<?php if ($type['discontinue'] = '0' || !$type['discontinue']): ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?> - <?php echo $type['company:label'];?></option>
<?php else: ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?> - DISCONTINUED - <?php echo $type['company:label'];?></option>
<?php endif; ?>
<?php elseif ($type['company'] == $CURRENT_USER['assigned_to']): ?>
<?php if ($type['discontinue'] = '0' || !$type['discontinue']): ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?></option>
<?php else: ?>
<option value = "<?php echo $type['num'];?>"><?php echo $type['title'];?> - DISCONTINUED</option>
<?php endif; ?>
<?php endif; ?>
<?php endforeach ?>
</select>
                            <input type="submit" name="submit" value="Edit Claim Type">

nmsinc

By claire - June 3, 2015

I think I need more info here. Can you tell me what kind of behaviour are you seeing when the form is submitted? What are the contents of the $_REQUEST array?

I don't see anything offhand that looks wrong about this code.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - June 3, 2015

Hi Claire,

On submit it should append the record num to the end of the URL and subsequently load the page with the data. The URL address 'code-type-edit.php?num=3' should work. It maybe in the PHP header code!

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php require_once "../cmsAdmin/lib/viewer_functions.php"; ?>
<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = '../cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/report/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  
 // load record from 'code_types'
  list($code_typesRecords, $code_typesMetaData) = getRecords(array(
    'tableName'   => 'code_types',
    'orderBy'     => 'title',
    ));
  $code_typesRecord = @$claim_typesRecords[0]; // get first record

    
  // load records from 'agency'
  list($agencyRecords, $agencyMetaData) = getRecords(array(
    'tableName'   => 'agency',
    'orderBy'     => 'agency_name',
    'loadUploads' => false,
    'allowSearch' => false,
  ));

   $index_color = "15497D";
   //$index_color = "0944CE";
   $sub_color   = "C5D9ED";
   //$sub_color = "#92";
   $errorsAndAlerts = "";

  //
  $showSignupForm = true;

  // process form
  if (@$_REQUEST['save']) {

        
    // turn off strict mysql error checking for: STRICT_ALL_TABLES
    mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)

    // add member company
    
  
      //
      $query = "UPDATE `{$TABLE_PREFIX}code_types` SET

                      title                        = '".mysql_escape( $_REQUEST['title'] )."',
                      company                      = '".mysql_escape( $_REQUEST['company'] )."',               
                      discontinue                  = '".mysql_escape( $_REQUEST['discontinue'] )."',
                      updatedByUserNum             = '".mysql_escape( $CURRENT_USER['num'] )."',
                      updatedDate                  = NOW()
                      
                 WHERE num = '".mysql_escape( $_REQUEST['num'] )."'";
      mysql_query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
      $userNum = mysql_insert_id();


      // show thanks
      $errorsAndAlerts  = "Thanks, We've created/updated your Code Type.<br/><br/>\n";
      $errorsAndAlerts .= "<a href='http://www.reportpro1.com/start/code_types.php'>Click here to enter/edit another Code Type</a>.";

      $_REQUEST        = array(); // clear form values
      $showSignupForm  = false;
  
     }
   else
    // prepopulate form with current user values
    foreach ($code_typesRecords as $name => $value) {
    if (array_key_exists($name, $_REQUEST)) { continue; }
    $_REQUEST[$name] = $value;
  }
  
   $index_color = "15497D";
   //$index_color = "0944CE";
   $sub_color   = "C5D9ED";
  //$sub_color = "#92";


?>

nmsinc

By claire - June 3, 2015

Okay, what's the action variable on the <form> tag?

Also, this getRecords for the code type doesn't appear to be getting any specific record - is that intended?

// load record from 'code_types'
  list($code_typesRecords, $code_typesMetaData) = getRecords(array(
    'tableName'   => 'code_types',
    'orderBy'     => 'title',
    ));
  $code_typesRecord = @$claim_typesRecords[0]; // get first record

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - June 3, 2015

The get record should grab the record number from the end of the URL such as code_type?num=3!

Do I have an incorrect 'get' statement?

nmsinc

By nmsinc - June 3, 2015

Duh!

I could just kick myself -  thanks Clair.

nmsinc