Edited answer to reflect discoveries found in comment thread below for future readers
In your PHP files you need to update
$_POST[id]
to be
$_POST['id']
PHP will not now what id is, and therefor will evaluate to false, causing your script to exit, and fall into the loop you are describing.
This is also the case when you are using your $_SESSION array
$_SESSION[valid]
should be
$_SESSION['valid']
$_SESSION, $_POST, $_GET, $_REQUEST, etc are all associative arrays, in order to refer to any of their contents you need to specify the string that refers to the key they are located in.
Ok, in your if statement
if (!$_POST['id']) {
header( "Location: pick_modcontact.php");
exit;
} else {
session_start();
}
if ($_SESSION['valid'] != "yes") {
header( "Location: pick_modcontact.php");
exit;
}
You are checking to see if $_SESSION['valid'] does not equal yes, this will evaluate to true because you never set $_SESSION['valid'] = "yes" so it will always go back to pick_modcontact.php here.
Try updating it to be
if (!$_POST['id']) {
header( "Location: pick_modcontact.php");
exit;
} else {
session_start();
// let the script know that this is a valid contact
$_SESSION['valid'] = 'yes';
}
if ($_SESSION['valid'] != "yes") {
header( "Location: pick_modcontact.php");
exit;
}
Also
$option_block .= "<option value\"$id\">$f_name, $l_name</option>";
should be (you're misssing an equals sign) which means that on submit, it wont know the value of 'id'
$option_block .= "<option value=\"$id\">$f_name, $l_name</option>";