...

View Full Version : Sign up scripts?



Vanilla
02-25-2003, 08:03 PM
Hey, I'm using NeoMail, and I was wondering, where can I get some good scripts that allows my users to sign up? I'm pretty new at PHP, so, if somebody is willing to construct me through the process, it would be very helpful.

I just need a program that can allow users to sign up, and send an automatic validation email.

Any comments, help, or anything would really help out :)

missing-score
02-28-2003, 08:13 PM
Are you using a MySQL database? To send validation e-mail your web server / hosting company needs an smtp server.

Tell we what you are using and then I should be able to help you from there.

Vanilla
02-28-2003, 10:28 PM
Yeah, I think i am using what you mentioned, thanks for being interested in helping out :)

missing-score
02-28-2003, 11:29 PM
I dont have a MySQL database and I dont know much about MySQL. If you are using a MySQL database then you would be definate about it, not: i think, so I will try an example without using MySQL. Tell me if there are bugs and I will try and fix them. I will put this in 3 parts.

PART 1: make file signup.php

<form name="signup" action="complete.php" method="post">
Name: <input type="text" name="name" value="<?php echo $name ?>" /> <br />
Surname: <input type="text" name="surname" value="<?php echo $surname ?>" /> <br />
E-mail: <input type="text" name="email" value="<?php echo $email ?>" /> <br /><br />
Username: <input type="text" name="username" value="<?php echo $username ?>" /><br />
Password: <input type="password" name="pass1" /><br />
Re-enter password: <input type="password" name="pass2" /><br /><br />
<input type="submit" value="Submit" /><br /><br />
</form>



<?php if($failed == 'true'){
echo "Some information was not correct"; // For if they get sent back from the completion page
} ?>

___

BEAR IN MIND THAT YOU DO NOT HAVE TO HAVE THESE FIELDS, CHANGE DELETE AND ADD AS YOU WISH, JUST BE SURE TO EDIT THE PHP CODE.
___

missing-score
02-28-2003, 11:47 PM
PART 2: make file complete.php



<?php

$required = array($name,$email,$username,$pass1,$pass2); // Array of required fields ( eg $name, $email )


for ( $i = 0; $i < count($required); $i++ )
{
$replacedSpaces = str_replace(' ','',$required[$i]); // Check all required fields, and replace all spaces with nothing temporarily to make sure the person has not just put a space in each field.
if($required[$i] == '' || $replacedSpaces == '')
{
header('location:signup.php?failed=true');
}
}
if($pass1 != $pass2) // Check passwords match
{
header('location:signup.php?failed=true');
}
?>

_______

MAKE SURE THE ABOVE CODE GOES BEFORE THE HTML TAG ON YOUR PAGE
_______


<html>
<head>
<title>Complete signup</title>
</head>
<body>


<?php
if(!file_exists("$username$password.dat"))
{
$newfile = fopen("$username$password.dat");
fwrite($newfile,"$name|$sname|$email|$username|$pass1");
fclose($newfile);
echo "Account Created";
mail("you@youremail.com","You have a new user","The users name is: $name\n\n
The users surname is $surname\n\n
The users e-mail is $email\n\n
The users username is $username\n\n
The users password is $password","From: Me! <you@youremail.com>\n");
}
?>


This will create a new file for the user, and send an e-mail to you informing you of them. You should know that this script if off the top of my head so there may be a couple of bugs.

missing-score
02-28-2003, 11:59 PM
STEP 3: login.php

Again, include this code before the HTML tag.



<?php

if(file_exists($username) && file_exists($password) && $username != $password)
{
header('location:loggedinusers.php');
} else {
$status = "Not logged in yet";
}
?>



<form name="log" action="<?php echo $PHP_SELF ?>" method="post" />
<input type="text" name="username" />
<input type="password" name="password" />
</form>

<br /><br />


<?php echo $status ?> // Writes "Not logged in yet" if they have not logged in


I hope this helps...

Bear in mind that a MySQL database option is much better. I might resarch it and post back here with a new script. Post If you need any more help or find a bug.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum