This code is giving me an unknown index: page error. Can someone please tell me
ID: 3542995 • Letter: T
Question
This code is giving me an unknown index: page error. Can someone please tell me why?
<?php
function getInfo($page){
echo "<table width="100%" border="0" cellpadding="2" cellspacing="2" > ";
switch($page){
case "about":
echo "<tr> ";
echo "<td align="center"> A little about me...</td> ";
echo "</tr> ";
echo "<tr> ";
echo "<td>Age: 36<br> ";
echo "Gender: Female <br> ";
echo " Bio: some bull shit about me. ";
echo "</td> ";
echo "</tr> ";
break;
case "goals":
echo "<tr> ";
echo "<td align="center"> My goals...</b></td> ";
echo "</tr> ";
echo "<tr> ";
echo "<td>some bull shit about me. ";
echo "</td> ";
echo "</tr> ";
break;
default:
echo "<tr> ";
echo "<td align="center"> Welcome to my page please choose an interest below</b></td> ";
echo "</tr> ";
break;
}
echo "<tr> ";
echo "<td align="center">";
echo "<a href="funcQueryString.php">Home</a>";
echo "<br>";
echo "<a href="funcQueryString.php?page=about">About</a>";
echo "<br>";
echo "<a href="funcQueryString.php?page=goals">My goals</a>";
echo "</td> ";
echo "</tr> ";
echo "</table> ";
}
echo "<html>";
echo "<head>";
echo " <title>About Me</title>";
echo "</head> ";
echo "<body>";
getInfo($_GET['page']);
echo "</body> ";
echo "</html> ";
Explanation / Answer
I think there is a problem with getInfo($_GET['page']);
Try somethingl like $getinfo = (isset($_GET['page']) ? $_GET['page'] : null);