Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Passing multiple variables in using PHP and $_GET['']

Writer Sebastian Wright

I'm using PHP to create a link depending on a variable. Currently I have this line of code which I have used multiple times and works perfectly.

echo "<a href='specificAssignmentPage.php?
assignName=$value2'>$value2</a>";

The above is all on one line. On the receiving page I have

$assignmentName = $_GET['assignName'];

which retrieves the value from the URL.

However I want to pass multiple variables through the link which I've attempted with

echo "<a href='specificAssignmentPage.php?assignName=$value2'teacherYes=$isTeacher>$value2</a>";

And received with

$assignmentName = $_GET['assignName'];
$isTeacher = $_GET['teacherYes'];

I get this error: " Notice: Undefined index: teacherYes in /Applications/XAMPP/xamppfiles/htdocs/Quests/specificAssignmentPage.php on line 13"

I know that it's probably a basic syntax error with separating my statement but I would really appreciate some help. Thanks!

2

1 Answer

Use the & between each url parameters

?assignName=$value2&teacherYes=$isTeacher

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy