Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mypic = $_FILES['upload']['name']; //name of the upload button and name of the file
- $temp = $_FILES['upload']['tmp_name']; //temp name of the file
- $type = $_FILES['upload']['type']; //HOLDS the type of file
- //$filepath = $imageDir . $mypic;
- $name = $_POST['name'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $cpassword = $_POST['cpassword'];
- $link= mysqli_connect("localhost","root", "sunpas") or die("Try Again Later");
- if($name && $email && $password && $cpassword){
- if(filter_var($email, FILTER_VALIDATE_EMAIL)){
- if(strlen($password)>5){
- if($password==$cpassword){
- $link= mysqli_connect("localhost","root", "sunpas") or die("Try Again Later");
- mysqli_select_db($link,"testsite");
- $username= mysqli_query($link, "SELECT Name FROM users WHERE Name='$name'");
- $count = mysqli_num_rows($username);
- $useremail= mysqli_query($link, "SELECT Email FROM users WHERE Email='$email'");
- $checkemail = mysqli_num_rows($useremail);
- if($count!=0){
- include('links.php');
- echo "Name already exists! Please type another name";
- }
- if($checkemail!=0){
- include('links.php');
- echo "ERROR: Email already exists! Please type another email";
- }
- else
- {
- //mysqli_query($link, "INSERT INTO users(Name,Email,Password) VALUES('$name', '$email','$password')");
- if(($type=="image/jpeg") || ($type=="image/jpg") || ($type=="image/bmp")){
- move_uploaded_file($temp, "images/$mypic");
- echo "Funny Face!<p><img border='1' width='70' height='70' src='images/$mypic'><p>";
- $passwordmd5 = md5($password);
- $rval = mysqli_query($link, "INSERT INTO users(Name,Email,Password) VALUES('$name', '$email','$passwordmd5')");
- if (!$rval){
- die('could not enter data '. mysqli_error($link));
- }
- else{
- echo "Entered data successfully! <a href='home.php'>Login now!</a>";
- }
- }
- else{
- echo "This file has to be a jpeg, jpg or bmp!";
- }
- }
- }
- else{
- echo "Password does not match!";
- }
- }
- else{
- echo "password is too short! must be atleast 6 characters";
- }
- }
- else{
- echo "please type a valid email!";
- }
- }
- else{
- echo "You have to complete the form";
- }
- mysqli_close($link);
- include('links.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement