n.am n.am - 1 year ago 59
PHP Question

ID won't be sent to url

public function editVC(){
$currentUserID = $_GET['userID'];

$vaccineID = $_POST['vaccines'];
$ageID = $_POST['ages'];

if(VaccineModel::editDChildVC($vaccineID,$ageID,$dcomment,$currentUserID)) {
header('Location: https://autovaccines-peldorri.c9users.io/Classes/Views/viewChildVC.php?userID= $currentUserID');
} else {
echo $vaccineID;
echo $dcomment;
echo $currentUserID;
echo"cant add";

When it redirects, this is the resulted url


I can't seem to figure out why the variable won't be sent to the url, although I have tried echoing the variable
and it did echo the correct ID, this means the if condition applies and there is a value in the variable.

Answer Source

Variables don't expand inside single-quotes, use double-quotes, i.e.:

header("Location: https://autovaccines-peldorri.c9users.io/Classes/Views/viewChildVC.php?userID=$currentUserID");

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download