I have made a page so that you enter data into a form and then the data gets placed into a new page that will be used as a profile page. but my problem is that i also want the new page to look like this.
<html>
<head>
<title>The profile of <?php print "$username"; ?></title>
</head>
<body>
<?php
// Connects to your Database
mysql_connect("localhost", "email", "qwe") or die(mysql_error());
mysql_select_db("email") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['Key_BHI']))
{
$username = $_COOKIE['ID_BHI'];
$pass = $_COOKIE['Key_BHI'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{
header("Location: ../login.php");
}
//otherwise they are shown the admin area
else
{?>
<h1>Welcome <?php print "$username"; ?><br>
<?php include("show_profile_format.php"); ?>
<!--$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$-->
<?php
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: ../login.php");
}
?>
<!--$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$-->
</body>
</html>
Here is the page that currently creates the other page without the code to check the cookie.
<?php
$userinfo = "$_POST[username]";
$content =
'<html>
<head>
<title>The profile of <?php print "$username"; ?></title>
</head>
<body>
<h1>Welcome <?php print "$username"; ?><br>
<?php include("show_profile_format.php"); ?>
</body>
</html>'
?>
<?php
$userinfo = "$_POST[username]";
$file = "$userinfo.php";
$open = fopen($file, "a");
fwrite($open, $content);
fclose($open);
?>
<?php
$content = "<a href='$userinfo.php'>$userinfo</a>\r\n";
$file = "profiles.html";
$open = fopen($file, "a");
fwrite($open, $content);
fclose($open);
?>
Currently this way it works but if i place the other page inside the variable $content then it says:
Parse error: parse error in C:\wamp\www\d_bg,l_txt\users\add.php on line 92
line 92 is the one that says:
if(isset($_COOKIE['Key_BHI']))
thanks for all teh help you guys have given me.