Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('confff.php');
- //test to see if username is alfanumeric
- $testname=$_POST(username);
- if (!eregi("([^A-Za-z0-9])"),$testname){
- //test for duplicate names
- $query="SELECT * FROM users WHERE username ='$_POST(username)'";
- $result=mysql_query($query);
- $num=mysql_num_rows($result);
- if ($num == 0){
- //test for duplicate email
- $query2="SELECT * FROM users WHERE email = '$_POST[email]'";
- $result2=mysql_query($query2);
- $num2 = mysql_num_rows(result2);
- if($num2==0){
- //if emails and passwords match up
- if(($_POST['pass']==$_POST['pass2'])==$_POST['email2'])){
- //generate random confirmation code
- $confirmation_code=md5(uniqid(rand()));
- //get rid of all html from hackers
- $name=strip_tags($-POST['username']};
- $email=strip_tags($_POST['email']);
- $pass=strip_tags($_POST['[pass']);
- //insert data into database
- $sql="INSERT INTO temp SET code='$confirm_code', username='$name', '$email', '$pass'";
- if($result){
- $message="Your Confirmation link \r\n";
- $message="Click on this link to activate your account \r\n";
- $message="localhost/confirmation.php?passkey=$confirm_code";//dont forget!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- $sentmail=mail("$email",'Registration Confirmation',"$message",'From: admin@localhost');
- header("Location:thankyou.html");
- }
- else {
- echo "Not found your email in our database";
- }
- //if your email succesfully sent
- if($sentmail){
- echo "Your Confirmation link has been sent to your e-mail account";
- }
- else {
- echo "cannot send confirmation link to your e-mail adress";
- }
- }
- }
- else
- {
- header("location:badmatch.html");
- }
- }
- else
- {
- header("Location:emailinuse.html");
- }
- }
- else
- {
- header("Location:nameinuse.html");
- }
- //check for errors here if there are any
- }else{
- header("location:nameinuse.html");
- }
- }else{
- header("location:invalidname.htm");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement