WilliamNova Posted August 13, 2013 Share Posted August 13, 2013 I know undefined variables are simple to fix, but I can't seem to get this fixed at all. <?php include ("./inc/headerinc.php"); mysql_connect("localhost","root",""); mysql_select_db("mid"); $email = $_GET['email']; $check_email = mysql_query("SELECT * FROM users WHERE email='$email'"); $count = mysql_num_rows($check_email); if ($count == 1) { while ($row = mysql_fetch_assoc($check_email)) { $id = $row['id']; $firstname = $row['firstname']; $lastname = $row['lastname']; $email = $row['email']; $password = $row['password']; echo "<h2>$firstname's Profile</h2><br /> Name: $firstname $lastname<br /> Email: $email "; } } ?> In line 7 'email' is undefined. When I try using isset($_GET ['email']) the error goes away, but none of the information that's suppose to echo is displayed. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted August 13, 2013 Share Posted August 13, 2013 (edited) $email = isset($_GET['email']) ? $_GET['email'] : FALSE ; Then add in a check to make sure $email is not false. if(empty($email)) { // The variable $_GET['email'] doesn't exist. } else { // Other code. } You also need to escape the variable before you use it in a query, to make sure it is safe to use. Edited August 13, 2013 by PaulRyan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.