nexuzkid Posted August 7, 2012 Share Posted August 7, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266754-creating-a-php-file/ Share on other sites More sharing options...
requinix Posted August 7, 2012 Share Posted August 7, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/266754-creating-a-php-file/#findComment-1367406 Share on other sites More sharing options...
nexuzkid Posted August 7, 2012 Author Share Posted August 7, 2012 Hmm... haven't learned any of that yet, but I assumed that I could kind of make my own little version... i guess not. But thanks for the help... i'll put userprofiles on the shelf for now then. Quote Link to comment https://forums.phpfreaks.com/topic/266754-creating-a-php-file/#findComment-1367412 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.