Jump to content

Creating a .php file...


nexuzkid

Recommended Posts

Hello guys.

 

I am currently making a userprofile system, and I cant seem to create a .php file for the users.

 

Well anyway heres my register system:

 


	$user_profile = '<?php
$browserstring = $_SERVER["HTTP_USER_AGENT"];
$pos = strrpos($browserstring, "MSIE");
if($pos > 0) {
    header("Location:ie.html");
}
?>
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Frontpage</title>
	<LINK href="http://mydomain.com/style.css" rel="stylesheet" type="text/css">
	</head>
<body>
	<div id="wrapper">
		<div id="header">

			</div>
			<div id="usercon">
			<?php

					$username = $_SESSION["username"];
					$lastname = $_SESSION["lastname"];
					$firstname = $_SESSION["firstname"];

					//Check do we have username and password
					if(!$username && !$password){
					echo "Welcome Guest! <br> <a href=login.php>Login</a> | <a href=regi.php>Register</a>";
					}else{
					echo "".$firstname ." ". $lastname." <a  href="http://www.mydomain.com/logout.php"> Logout</a> | <a href=option.php>Option</a>";
								}	
				?>
		</div>

			<div id="content">
			<div id="info">
				<div id="profile_content">	
				<div id="profile_data">	
				</div>	
				<div id="profile_name">
				Name:'.$firstname.'	
				</div>
				<div id="profile_joindate">
				'.$date.'	
				</div>
				<div id="profile_info">
				'.$about.'
				</div>	
				</div>	
				</div>	
			</div>
			<div id="bottom">

				<br />
				<br />
			</div>
	</div>
</body>
</html>		';	

					$fil = fopen("/users/".$username.".php","w");
					$order = "";
					fwrite($fil,$order);  
					fclose($fil); 
					echo "Click <a href='/users/$username.php'>here</a> to view your profile!";

	}
	?>		

 

Though i get an error saying:

 

Warning: fopen(/users/nexuzkid.php) [function.fopen]: failed to open stream: No such file or directory in register.php on line 330

 

Warning: fclose(): supplied argument is not a valid stream resource in register.php on line 333

 

Regards,

 

nexuzkid

Link to comment
Share on other sites

Oh dear.

 

What you're trying to do is a very, very bad idea. The correct thing to do has two parts:

1. Use URL rewriting to send every request to /users/username to one single PHP script, such as /user.php?username=username. This can happen behind-the-scenes so the user won't notice it happening.

2. Put some logic and code into that one script so that it outputs what it needs to output. For instance, if you save profile information to a database then your script can output it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.