SamNewbie Posted April 7, 2014 Share Posted April 7, 2014 Hello, I need some help on my PHP coding. I need the ?=ID to show up on the URL when the user logs in and then to be able to use GET['id'] to show the results (first name, surname, dob etc). Below is my coding I have so far: Heading.php - this is where the user will log in. <div id="heading"> <h2>Sports Pal</h2> <h5>Playing the same sport as you!</h5> <h5><a href="@">Home</a>: <a href="@">About</a>: <a href="@">Contact</a>: <a href="@">Advertise</a></h5> <div class="signin"><?php if ($_SESSION['loggedin'] == true){ echo "<p>You are logged in.</p>\n"; }else{ echo "<p>Sign In:</p>\n"; }?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Username: <input type="text" name="liusername"> Password: <input type="password" name="lipassword"> <input type="submit" name="lisubmit" value="Sign In"> </form> </div> </div> Source code on profile.php <?php include "./includes/nav.php";?><div id="content"> <h3>User Profile</h3> <?php $query="SELECT user_id, user_firstname, user_surname, user_dob, user_gender FROM user"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result); if ($_GET['id'] == $_SESSION['id']); //if (isset($_GET['id'])){ //$_GET['id'] == $_SESSION['id']; echo "<label>First Name: </label>"; echo $row['user_firstname']."<br />"; echo "<label>Surname: </label>"; echo $row['user_surname']."<br />"; echo "<label>Date of Birth: </label>"; echo $row['user_dob']."<br />"; echo "<label>Gender: </label>"; echo $row['user_gender']."<br />"; echo "<label>City: </label>"; ?> <br /> </div> Many thanks for your help Quote Link to comment Share on other sites More sharing options...
Solution cyberRobot Posted April 7, 2014 Solution Share Posted April 7, 2014 It looks like you're trying to have someone log in using the form. Once the form is submitted, you want to pull the user's information from the database which corresponds with the passed log in. If that's the case, you'll need to use $_POST variables since the form is set to POST. Once you're familiar with using POST variables, you'll need to add them to a WHERE clause in your query. Don't forget to use mysql_real_escape_string(): http://www.php.net/mysql_real_escape_string 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.