Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // call ths shizzle
- require_once ('_db.php.inc'); // include the database
- require_once ('_functions.php.inc'); // include the functions
- // DO LOGIN SHIT
- $emaillog = mysql_escape_string($_POST['emaillog']);
- $passwordlogunsalted = mysql_escape_string($_POST['passwordlog']);
- $passwordlog = salt($passwordlogunsalted);
- if (!empty($emaillog) AND !empty($passwordlog))
- {
- $sql = "SELECT *
- FROM `users`
- WHERE `email` = '$emaillog'
- AND `password` = '$passwordlog'";
- $result = mysql_query($sql);
- $num = mysql_num_rows($result);
- if ($num > 0)
- {
- $row = mysql_fetch_array($result);
- session_start();
- $_SESSION['id'] = $row['id'];
- $_SESSION['email'] = $row['email'];
- header('location: dashboard.php');
- }
- }
- // DO REGITRSTION SHIT
- $emailreg = mysql_escape_string($_POST['emailreg']);
- $passwordregunsalted = mysql_escape_string($_POST['passwordreg']);
- $passwordreg = salt($passwordregunsalted); // salt the password
- $first_name = mysql_escape_string($_POST['first_name']);
- $last_name = mysql_escape_string($_POST['last_name']);
- $cellnumber = mysql_escape_string($_POST['cellnumber']);
- if (!empty($emailreg) AND !empty($passwordreg) AND !empty($first_name) AND !empty($last_name) AND !empty($cellnumber))
- {
- if (isset($_FILES['image']))
- {
- // if the selected to upload an avatar, do that now.
- // do file upload shit. be careful you didn't upload this.
- $temp_folder = "temp/";
- $destination = "uploads/";
- $errors = 0;
- $accepted = array("image/gif","image/jpeg","image/png");
- if (in_array($_FILES["image"]["type"], $accepted))
- {
- $extension = substr(strrchr($_FILES["image"]["name"], '.'), 1);
- $new_filename = mktime().".".$extension;
- $temp_file = $temp_folder.$new_filename;
- $final_file = $destination.$new_filename;
- if (!file_exists($temp_file))
- {
- $upload = move_uploaded_file($_FILES["image"]["tmp_name"], $temp_file);
- if ($upload)
- {
- include("_resize-class.php.inc");
- $resizeObj = new resize($temp_file);
- $resizeObj -> resizeImage(38, 36, 'crop');
- $resizeObj -> saveImage($final_file, 100);
- }
- else
- {
- $errors++;
- $error_message = "File could not be moved.";
- }
- }
- else
- {
- $errors++;
- $error_message = "File exists, Cannot upload.";
- }
- }
- else
- {
- $errors++;
- $error_message = "Invalid file type.";
- }
- if ($errors > 0)
- {
- die($error_message);
- }
- // end file upload shit. $final_file is the thing that you want to play with.
- }
- if (empty($final_file))
- {
- $final_file = 0;
- }
- $sql = "SELECT * from users WHERE email='$emailreg'";
- $result = mysql_query($sql);
- if (mysql_num_rows($result) < 1)
- {
- $sql = "INSERT INTO `batch_board`.`users` (`id`, `email`, `password`, `first_name`, `last_name`, `cellnumber`, `avatarurl`) VALUES (NULL, '$emailreg', '$passwordreg', '$first_name', '$last_name', '$cellnumber', '$final_file');";
- mysql_query($sql);
- echo "You've registered!";
- }
- else
- {
- echo "that username is taken I think";
- }
- }
- ?>
- <h1>register</h1>
- <form name="input" enctype="multipart/form-data" action="index.php" method="post">
- Email: <input type="text" name="emailreg" /><br />
- Password: <input type="password" name="passwordreg" /><br />
- First Name: <input type="text" name="first_name" /><br />
- Last Name: <input type="text" name="last_name" /><br />
- Cell Number: <input type="text" name="cellnumber" /><br />
- Upload an avatar: <input type="file" name="image" ><br>
- <input type="submit" value="Submit" />
- </form>
- <br />
- <h1>login</h1>
- <form name="input" action="index.php" method="post">
- Username: <input type="text" name="emaillog" /><br />
- Password: <input type="password" name="passwordlog" /><br />
- <input type="submit" value="Submit" />
- </form>
Add Comment
Please, Sign In to add comment