Jump to content

shizzledizzleeee

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by shizzledizzleeee

  1. <?php
    $host = 'localhost';
    $username = 'root';
    $password = '';
    $datadase = 'registerfinal';
    $connect = mysqli_connect($host, $username, $password) or die ('error to connect to datadase'.mysqli_error());
    if ($connect) {
        echo 'mysqli connect succsessfull';
    }
    echo '<br /><br />';
    $selectdb = mysqli_select_db($connect, $datadase) or die ('unable to select datadase'.mysqli_error());
    if($selectdb) {
        echo 'database selected succsessfully';
    }
    
    if(isset($_POST['savedetails'])) {
            
        $firstname = $_POST['firstname'];
        $lastname = $_POST['lastname'];
        $username = $_POST['username'];
        $password = $_POST['password'];
        $repeat_password = $_POST['repeat_password'];
        $gender = $_POST['gender'];
        $country = $_POST['country'];
        
        
        if(isset($_POST['food'])) {
        $food = $_POST['food'];
        $favfood = "";
        foreach($food as $meal ) {
        $favfood = $meal.",";    
        print_r($favfood);
        }
    }
        
        if(isset($_POST['imageUpload'])) {
        $imageUploadname = $_FILES['imageUpload']['name'];
        $imageUploadsize = $_FILES['imageUpload']['size'];
        $imageUploadtmp_name = $_FILES['imageUpload']['tmp_name'];
        $imageUploadtype = $_FILES['imageUpload']['type'];
        $uploadFolder = "uploadFolder/";
        $destinationName = rand(1000, 10000).$imageUploadname;    
        
        move_uploaded_file($imageUploadtmp_name, $uploadFolder.$destinationName);
        echo "$imageUploadname";
        echo "$imageUploadsize";
        echo "$imageUploadtmp_name";
        echo "$imageUploadtype";
        echo "$destinationName";
        
        }
        $sqltwo = "INSERT INTO `registerfinaltable` (`id`, `firstname`, `lastname`, `username`, `password`, `repeat_password`, 
        `gender`, `food`, `country`, `imageUploadname`, `imageUploadsize`, `imageUploadtype`)
        VALUES (NULL, '$firstname', '$lastname', '$username', '$password', '$repeat_password', '$gender', '$favfood', '$country',
        '$destinationName', '$imageUploadsize', '$imageUploadtype')";
        
        $results = mysqli_query($connect, $sqltwo) ;
        if($results){
            
        echo "inserted successfully";
        }
    }
    
    ?>
    
    
    <html>
    <head>
    <title>register</title>
    
    </head>
    
    <body>
    <form action = "" method = "post"  enctype = "multipart/form-data"  >
    <label>first name : <input type = "text" name = "firstname" /> </label> <br /><br />
    <label>last name : <input type = "text" name = "lastname" /> </label><br /><br />
    <label>username : <input type = "text" name = "username" /> </label><br /><br />
    <label>password : <input type = "password" name = "password" /> </label><br /><br />
    <label>repeat password : <input type = "password" name = "repeat_password" /> </label><br /><br />
    <label>Male :   <input type = "radio" name = "gender" value = "Male" /> </label><br /><br />
    <label>Female : <input type = "radio" name = "gender"  value = "Female" /> </label><br /><br />
    <label>pizza : <input type = "checkbox" name = "food[]" value = "pizza"/> </label><br /><br />
    <label>burger : <input type = "checkbox" name = "food[]" value = "burger"/> </label><br /><br />
    <label>chips : <input type = "checkbox" name = "food[]" value = "chips"/> </label><br /><br />
    <label>sausage : <input type = "checkbox" name = "food[]" value = "sausage"/> </label><br /><br />
    <label>sandwich : <input type = "checkbox" name = "food[]" value = "sandwich"/> </label><br /><br />
    <label>Image : <input type = "file" name = "imageUpload" /> </label><br /><br />
    <select name = "country">
    <?php
    $sql = 'SELECT * FROM `countrie` ';
    $querry = mysqli_query($connect, $sql);
    while($country = mysqli_fetch_array($querry)):;
    
    ?>
    
    <option value = "<?php echo $country['country']; ?>"><?php echo $country['country']; ?></option>
    <?php endwhile;?>
    
    
    </select> <br />
    
    
    <input type = "submit" name = "savedetails" />
    
    
    
    </form>
    <table border = "1" bgcolor = "" width = "100%">
    <tr><th>id</th><th>Firstname</th><th>Lastname</th><th>Username</th><th>Password</th><th>Password 2</th><th>Gender</th><th>Fav. Food</th> <th>Image</th> <th>Country</th><th>imageUploadname</th><th>imageUploadsize</th><th>imageUploadtype</th></tr>
    <?php 
    $sqldata = "SELECT * FROM registerfinaltable";
    $querysqldata = mysqli_query($connect, $sqldata);
    while($rows = mysqli_fetch_array($querysqldata) ):;
    ?>
    <tr>
    <td><?php echo $rows['id'];?></td>
    <td><?php echo $rows['firstname'];?></td>
    <td><?php echo $rows['lastname'];?></td>
    <td><?php echo $rows['username'];?></td>
    <td><?php echo $rows['password'];?></td>
    <td><?php echo $rows['repeat_password'];?></td>
    <td><?php echo $rows['lastname'];?></td>
    <td><?php echo $rows['gender'];?></td>
    <td><?php echo $rows['food'];?></td>
    <td><?php echo $rows['country'];?></td>
    <td><?php echo $rows['imageUploadname'];?></td>
    <td><?php echo $rows['imageUploadsize'];?></td>
    <td><?php echo $rows['imageUploadtype'];?></td>
    <?php endwhile;?>
    </tr>
    </table>
    </body>
    </html> 
    

    dc3a9384f5c6987af087fad165295ac5.png

    post-189690-0-49613600-1475505107_thumb.png

×
×
  • Create New...