Problem with $_GET (getting variables from a href) - PHP & MySQL - Kevin Yank
I recently started reading PHP & MySQL Novice to Professional by Kevin Yank. I ran into a problem on the second example I attempted to use in the book.
So this is what I tried to do:
I'm trying to send firstname and lastname to $_GET, which the file name.php will handle. Which is located in the same folder.
<a href="name.php?firstname=Kevin&lastname=Yank">Hi, I’m Kevin!</a>
Here's the PHP:
The output looks like this:
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
echo 'Welcome to our website, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!';
Notice: Undefined index: firstname in C:\apache\htdocs\Novice2Professional\HTMLandPHP\name.php on line 2
Notice: Undefined index: lastname in C:\apache\htdocs\Novice2Professional\HTMLandPHP\name.php on line 3
Welcome to our website, !
I think the problem is with the & in the HTML. I could send one value just fine.