PDA

View Full Version : member able to make his own site?


jeremy
09-17-2002, 08:45 PM
ok i just made my members area site. how do i allow my members to create their own page on my site?

i want to make a form in which they choose which prefrences they want and when they submit it, it creates a txt file.. and a php file displays the txt file.

Paul
09-17-2002, 08:54 PM
Do you have mySQL? If you do it would be much better to use that then file.txt. Look here for a great tutorial:
http://www.freewebmasterhelp.com/tutorials/phpmysql/
Good Luck,
Paul

jeremy
09-18-2002, 10:22 AM
yes i do have mysql. thats how my members area runs.

basically i want each member to have induhvuial pages when they sign up.

then they can create thier own webpage.. (profile i guess)

now, does that website tell you how to do that?

Paul
09-18-2002, 04:44 PM
Originally posted by jeremy
yes i do have mysql. thats how my members area runs.

basically i want each member to have induhvuial pages when they sign up.

then they can create thier own webpage.. (profile i guess)

now, does that website tell you how to do that?
It does, just go through it, doesn't say directly but if you read it you will figure it out. Basiclly you will have to add their data to a DB, and then just call it based on the ID using the 'WHERE' tag PHP has built in. After you read it and are still having problems let me know.
Good Luck,
Paul

jeremy
09-19-2002, 09:51 AM
i'm still having problems.

:(

this what i exactly want:

the person signups up on my form:
http://jeremy.resource-locator.com/members/signup.php

when they click "Sign Up", it automatically creates a text file in the /members/ folder with the member's username as the file name. then once they login:

http://jeremy.resource-locator.com/members/index.php

and click 'Next', it opens up: "users.php?name=USERNAME"

Here is my code:

(signup.php)
<?
if(!$submit)
{
?>
<html>
<head><title>Sign Up!</title></head>
<body>
<p>Please sign up by filling in the form below!</p>
<form name="signup" method="POST" action="signup.php">
<p>Username:<input type="text" name="username"></p>
<p>Password:<input type="password" name="password"></p>
<p>Verify Password:<input type="password" name="password2"></p>
<p>Email:<input type="text" name="email"></p>
<p><input type="submit" name="submit" value="Sign Up!"></p>
<p><input type="reset" name="reset"></p>
</form>
</body>
</html>
<?
}
else
{
//Now we can insert the data, as form has been submitted

//check that passwords entered are the same
if($password !== $password2)
{
?>
<p>The passwords you entered did not match.</p>
<?
exit();
}

//insert info into database
$connect = mysql_connect("localhost","USERNAME","PASSWORD");
mysql_select_db("DATABASE-NAME",$connect);
$query = "INSERT INTO members(username,password,email) VALUES('$username','$password','$email')";
$result = mysql_query($query);
mysql_close($connect);

if($result)
{
?>
<html>
<head><title>Sign Up Complete!</title></head>
<body>
<p>All Done! Thanks for signing up!</p>
</form>
</body>
</html>
<?
}
else
{
?>
<html>
<head><title>Error!</title></head>
<body>
<p>There was an error in adding your data. Please try again!</p>
</form>
</body>
</html>
<?
}
}
?>

Here is next.php:

<?
session_start();
if(session_is_registered(username)){
include("moo.php");
}else{
echo "You are not logged in. You must be logged in to see this page";
}
?>

Here is moo.php:

<B>Welcome, <? echo $username ?></B>
<BR>
<BR><BR><BR>
<p align="right"> <font size="-1"><a href="logout.php">Goodbye</a></font>

Here is login.php (the page you go automatically after login):

<?
session_start();
$db_host = "localhost";
$db_user = "USERNAME";
$db_pass = "PASSWORD";
$db_name = "DATABASE-NAME";

// check login and password
// connect and execute query
$connection = mysql_connect($db_host, $db_user, $db_pass) or die
("Unable to connect!");

$query = "SELECT * FROM members WHERE username='$username' AND password='$password'";
$result = mysql_db_query($db_name,$query,$connection);
$total = mysql_num_rows($result);
if($total==0 || $username ==" "|| $password == '')
{
?>
<p>Login Error</p>
<p>Sorry. Your username is incorrect. Please try again.</p>
<script>
function back()
{
location.href="<? echo $HTTP_REFERER ?>";
}
setTimeout("back()",6000);
</script>
<?
halt;
}
else
{
list($id,$password)=mysql_fetch_row($result);
if($password!==$password)
{
?>
<p>Login Error</p>
<p>I'm sorry but your password is incorrect. Please try again!</p>
<?
halt;
}
else
{

session_register("username");
echo 'You are now logged in. Please wait while you are redirected.';
?>
<script>
function next()
{
location.href="members.php";
}
setTimeout("next()",4000);
</script>
<?
}
}?>

Here is members.php: (if you'd like to know)
<?
session_start();
?>

<html>
<head>
<basefont face="Verdana">
</head>

<body>

<center>
Thank you for logging in!<BR><? echo $username ?><BR><BR><a href="next.php">Next</a></center> <p
align="right"> <font size="-1"><a href="logout.php">Goodbye</a></font>
</body>
</html>

d_smiff
09-19-2002, 11:33 AM
I don't really understand why it is you want to create a txt file on the server, if you have access to a MySQL database. You can obviously store all information that you need to about the members in there. :confused:

DA Master
09-19-2002, 01:45 PM
I was thinking the same d_smiff. Why not use a MySQL database when you have access to it. The data is much easier to edit, add and manipulate.

jeremy
09-19-2002, 07:38 PM
ok then.. just give me some code! :D

jeremy
09-22-2002, 07:53 AM
please? :(