Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('db.php');
- // If form submitted, insert values into the database.
- if (isset($_REQUEST['username'])){
- $username = stripslashes($_REQUEST['username']); // removes backslashes
- $username = mysqli_real_escape_string($con,$username); //escapes special characters in a string
- $email = stripslashes($_REQUEST['email']);
- $email = mysqli_real_escape_string($con,$email);
- $password = stripslashes($_REQUEST['password']);
- $password = mysqli_real_escape_string($con,$password);
- $picture = $_FILES['foto']['tmp_name'];
- $img_name = $_FILES['foto']['name'];
- $dir = "/var/www/uploads/";
- $path = $dir.$img_name;
- move_uploaded_file( $picture, $path );
- $date = date("Y-m-d H:i:s");
- $query = "INSERT into `users` (username, password, email, picture, date) VALUES ('$username', '".md5($password)."', '$email', '$picture' ,'$date')";
- $result = mysqli_query($con,$query);
- if($result){
- echo "<div class='form'><h3>You are registered successfully.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
- }
- }else{
- <form name="registration" action="" method="post">
- Upload Imagen : <input type="file" name="foto" />
- <input type="text" name="username" placeholder="Username" required />
- <input type="email" name="email" placeholder="Email" required />
- <input type="password" name="password" placeholder="Password" required />
- <input type="submit" name="submit" value="Register" />
- </form>
- minha Database
- CREATE TABLE `users` (
- `id` int(11) NOT NULL,
- `username` varchar(50) NOT NULL,
- `email` varchar(50) NOT NULL,
- `password` varchar(50) NOT NULL,
- `picture` varchar(100) NOT NULL,
- `level` tinyint(1) NOT NULL DEFAULT '0',
- `ative` tinyint(1) NOT NULL DEFAULT '0',
- `date` datetime NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement