here is the code that creates a simple profile of a user with list of posts :
<html>
<head>
<title>Welcome ! </title>
</head>
<body>
<?php
$dbcon = mysql_connect('localhost','user','password');
if(!$dbcon)
{
die('<p>'.'Unable to connect to database server'.mysql_error().'</p>');
}
?>
<?php
//select the database
mysql_select_db("rough_site",$dbcon);
//add the user
$user_name = mysql_real_escape_string($_POST['user_name'];
$user_password =mysql_real_escape_string($_POST['user_password'];
$user_mail=mysql_real_escape_string($_POST['user_mail'];
$adduser= "INSERT INTO user (user_name, user_password, user_mail) VALUES ($user_name,
$user_password, $user_mail)";
$confirmUser = mysql_query($adduser);
if(!$confirmUser)
{
die("Sorry , but you could not be added as a member of this site . ");
}
?>
<p align="center" ><h2><em>Latest posts by you </em></h2></p><br/>
<?php
// show the latest posts by this user
$user_name = $_POST['user_name'];
$latestposts = "SELECT post_id , post_title from posts ,users where
posts.user_name=users.$user_name " ;
$showlatestposts= mysql_query($latestposts);
?>
<blockquote>
<?php
while($row=mysql_fetch_array($showlatestposts) )
{
echo '<p>'. '<a href = "showpost.php?post_id='. $row['post_id'].'">'.
$row['post_title'].'</a></p><br/>' ;
}
?>
</blockquote>
</body>
</html>
To insert value from array with named key to string, and to use
''marks, you must enclose it in{}– http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing (Complex (curly) syntax)So, for example,
must be