Reputation: 1
I'm making a very simple web app (for the first time, all this is new to me). I've got a few PHP scripts set up to work with an SQL database to manage user login and registering, but now I want to create something to automatically generate a personal HTML page for a user when they register that displays certain information about them. I'm not sure how to go about doing this.
Upvotes: 0
Views: 127
Reputation: 886
You would create a PHP script that outputs the user's personal HTML page by checking a username passed to the page by a $_GET variable for example:
$username = $_GET['username']
With this username you can add a WHERE clause to your SQL query (don't forget to mysql_real_escape_string($username) before you do that) and retrieve only the info pertaining to that specific user.
Check mysql_fetch_array for a way to retrieve info from the result of a mysql_query.
And the links to a specific user page would look like this:
http://www.youraddress.com/users.php?username=Dylan
Upvotes: 3
Reputation: 27618
You need to:
SELECT username, dob, gender FROM users WHERE userid = $_SESSION['userid'];
) - Don't forget to sanitize userid.echo $userData['username']
)Upvotes: 4
Reputation: 522125
Easiest way:
exmaple.com/user.php?user=123
<?php
$userId = $_GET['user'];
$userInfo = // fetch info from database
?>
<h1>User <?php echo $userInfo['username']; ?></h1>
...
Upvotes: 3