Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_SERVER['REQUEST_METHOD'] == 'POST'){
- //import database connetion
- $serverName = "localhost";
- $userName = "root";
- $password = "";
- $dbName = "assignment";
- $con = new mysqli($serverName, $userName, $password, $dbName);
- if ($con->connect_error){
- die("Connection failed: ".$conn->connect_error);
- }
- //grab value
- $m_name = $_POST["name"];
- $m_bday = $_POST["birthday"];
- $m_pass = $_POST["rpassword"];
- $upload = 1 ;
- $image = $_FILES["image"]["tmp_name"];
- $img_temp = file_get_contents($image);
- $img = "uploads/";
- $img_file = $img. basename($_FILES["image"]["name"]);
- $img_type = pathinfo($img_file,PATHINFO_EXTENSION);
- $check = getimagesize($_FILES["image"]["tmp_name"]);
- if($check !== false) {
- echo "<h1>File is image - " . $image;
- $upload = 1;
- } else {
- echo "<center><h1>File is not an image.<br>";
- $upload = 0;
- }
- if($upload == 1){
- if($img_type != "jpg" && $img_type != "png" && $img_type != "jpeg" && $img_type != "gif" ) {
- echo "<h1>Sorry, the file type uploaded is not allowed.<br>";
- $upload = 0;
- }
- else{
- echo "<h1>Image result: ". $image;
- $sql = "INSERT INTO member (name, birthday, password, image)
- VALUES ('$m_name', '$m_bday', '$m_pass', '$image')";
- if ( $con->query($sql)){
- header("Location: member.php");
- }
- }
- }
- if ($upload == 0){
- echo "<h1>Error registration.<br>";
- echo "<h1><center><a href='register.php'>Back To Registration</a>";
- }
- /*if (isset($_FILES)){
- $image = $_FILES["image"]["tmp_name"];
- $img_temp = file_get_contents($image);
- echo "Image result: ". $image;
- }
- else{
- echo "error on image";
- }*/
- /*$sql = "INSERT INTO member (name, birthday, password, image)
- VALUES ('$m_name', '$m_bday', '$m_pass', '$image')";
- if ( $con->query($sql)){
- header("Location: login.php");
- }*/
- $con->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement