Jump to content

Issue with form activating


rodb

Recommended Posts

I have a form that is built, I thought like the those but does not display (display an error message generated on second pass of retrieving the passed parameters). On the initial pass from calling form, variables appear correctly.  However, on the second call (pretty sure it is the form method line does not pass the variable.

<?php
  require_once('includes/load.php');
  if (!$session->isUserLoggedIn(true)) { redirect('index.php', false);}
?>

<?php
    $person = find_by_people_id((int)$_GET['id']);
       error_log("all person id = " . $person['id'] . "\n",3, "./my-errors.txt");
       error_log("all persons = " . $person . "\n",3, "./my-errors.txt");
    $all_cats = all_people_categories();
       error_log("person id = " . $person['id'] . "\n",3, "./my-errors.txt");
       
    $query = "select * from people where id = '{$person['id']}'";
    $result = mysqli_query($con, $query);
    $data = mysqli_fetch_row($result);
    error_log("lname = " . $data[1] . "\n",3, "./my-errors.txt");

if(!$person){
  $session->msg("d","Missing person id.");
  redirect('people.php');
}
?>

<?php include_once('layouts/header.php'); ?>

  <div class="row">
     <div class="col-md-12"><p class="title"><span class="red"><?php echo $person['lastname'] . ", " . $person['firstname']; ?></span></p></div>
  </div>
  <div class="row">
     <div class="col-md-12"><p class="title">Edit Person</p></div>
  </div>

 <div class="padding-top">
 <div class="box">
    <div class="row">
      <div class="col-md-6">
        <?php echo display_msg($msg); ?>
      </div>
     <form method="post" action="edit_person.php?id=<?php echo (int)$person['id']; ?>" >
      <div class="row">
        <div class="col-xs-3">
          <div class="form-group">
            <div class="input-group">
              <span class="input-group-addon">
                <i class="glyphicon glyphicon-th-large"></i>
              </span>
              <input type="text" class="form-control" name="person-lname" value="<?php echo remove_junk($person['lastname']);?>" >
              <span class="input-group-addon">Last name</span>
           </div>
          </div>
        </div>
        <div class="col-xs-3">
          <div class="form-group">
            <div class="input-group">
              <span class="input-group-addon">
                <i class="glyphicon glyphicon-th-large"></i>
              </span>
              <input type="text" class="form-control" name="person-fname" value="<?php echo remove_junk($person['firstname']);?>">
              <span class="input-group-addon">First name</span>
           </div>
          </div>
        </div>
        <div class="col-xs-3">
          <div class="form-group">
            <div class="input-group">
              <span class="input-group-addon">
                <i class="glyphicon glyphicon-th-large"></i>
              </span>
                <?php  foreach ($all_cats as $cat): ?>
                     <?php if($person['cat_id'] == $cat['id']): ?>
                    <?php echo remove_junk($cat['descrip']); endif ?>
                <?php endforeach; ?>
              <input type="text" class="form-control" name="person-cat" value="<?php echo remove_junk($cat['id']);?>">
              <span class="input-group-addon">Category</span>
           </div>
          </div>
        </div>
        </div>
        </form>
    </div>
    </div>
  </div>

<?php include_once('layouts/footer.php'); ?>

 

Can not see why the variable is missing.  The function "find_by_people_id" is below:

 

  function find_by_people_id($id){
    global $con;
    $p_id = (int)$id;
    $sql  = " SELECT * FROM people WHERE id = '{$id}'";
    $row = mysqli_query($con,$sql);
    check_query($row);
    if($result = mysqli_fetch_assoc($row)){
      return $result;
    } else {
      return null;
    }
  }

 

Thanks for any help.

Rod

Edited by rodb
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.