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:
<a href="name.php?firstname=Kevin&lastname=Yank">Hi, I’m Kevin!</a>
I'm trying to send firstname and lastname to $_GET, which the file name.php will handle. Which is located in the same folder.
Here's the PHP:
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
echo 'Welcome to our website, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!';
The output looks like this:
Notice: Undefined index: firstname in C:\apache\htdocs\Novice2Professional\HTMLandPHP\
ame.php on line 2
Notice: Undefined index: lastname in C:\apache\htdocs\Novice2Professional\HTMLandPHP\
ame.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.