rodb Posted September 14, 2015 Share Posted September 14, 2015 (edited) 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 September 14, 2015 by rodb Quote Link to comment https://forums.phpfreaks.com/topic/298160-issue-with-form-activating/ Share on other sites More sharing options...
hansford Posted September 14, 2015 Share Posted September 14, 2015 You have a form with a method of "post" but are attempting to retrieve the id via $_GET....should match your form method...$_POST Quote Link to comment https://forums.phpfreaks.com/topic/298160-issue-with-form-activating/#findComment-1520807 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.