Results 1 to 19 of 19
Nov 21, 2012, 16:38 #1
- Join Date
- Nov 2012
- 0 Post(s)
- 0 Thread(s)
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:
<a href="name.php?firstname=Kevin&lastname=Yank">Hi, I’m Kevin!</a>
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') . '!';
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.