Advertisement
Guest User

Untitled

a guest
May 28th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.96 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. if(!isset($_SESSION['user']))
  6. {
  7.   header("Location:index.php");
  8. }
  9. ?>
  10.  
  11. <!DOCTYPE html>
  12. <html>
  13.     <head>
  14.     <title>ACTIV8</title>
  15.     <div class="container">
  16.       <a href="logout.php">Logout</a>
  17.       <a href="index.php">ACTIV8</a>
  18.       <a href="profile.php">Profile</a>
  19.       <a href="event.php">Events</a>
  20.       <a href="booking.php">Booking</a>
  21.       <a href="om.php">About</a>
  22.       <a href="friends.php">Training Partners</a>
  23.     </div>
  24.     </head>
  25.     <body>
  26.       <h1 class="title_h1"> This is your profile</h1>
  27.      <?php
  28. session_start();
  29.  
  30. require'anslutning.php';
  31.  
  32. if (isset($_POST['upload'])){
  33.         $target = "pictures/".basename($_FILES['image']['name']);
  34.  
  35.         $image = $_FILES['image']['name'];
  36.         $userId = $_SESSION['user'];
  37.    
  38.         $sql= "UPDATE user SET image='$image' WHERE user_id = $userId";
  39.    
  40.         if($con->query($sql)===TRUE)
  41.         {
  42.             echo("Information updated");
  43.         }
  44.         else
  45.         {
  46.     echo"Error:".$sql."<br>".$con->error;
  47.     }
  48.    
  49.  
  50.  
  51.         $sql = "INSERT INTO user (image) VALUES ('$image') WHERE user_id = '$userId'";
  52.         mysqli_query($con, $sql);
  53.  
  54.  
  55.         if (move_uploaded_file($_FILES['image']['tmp_name'], $target)){
  56.             echo "Image uploaded sucessfully";
  57.         }
  58.         else {
  59.             echo "There was a problem uploading image";
  60.         }
  61. }
  62.        
  63.        
  64. if(!empty($_POST['password_edit'])|| !empty($_POST['info_edit'])|| !empty($_POST['sex_edit'])|| !empty($_POST['age_edit'])|| !empty($_POST['sport_edit']))
  65. {
  66.   $password=mysqli_real_escape_string($con,$_POST['password_edit']);
  67.   $info=mysqli_real_escape_string($con,$_POST['info_edit']);
  68.   $sex=mysqli_real_escape_string($con,$_POST['sex_edit']);
  69.   $age=mysqli_real_escape_string($con,$_POST['age_edit']);
  70.   $sport=mysqli_real_escape_string($con,$_POST['sport_edit']);
  71.   $_SESSION['usersport'] = $sport;
  72.   $salt= uniqid(mt_rand(),true);
  73.   $password=$password.$salt;
  74.   $password=sha1($password);
  75.  
  76.  
  77.  
  78.   $results=$con->query("SELECT * FROM User WHERE email ='$email'");
  79.   $records=$results-> fetch_assoc();
  80.   if(count($records)> 0)
  81.   {
  82.     die("Username already exists");
  83.   }
  84.   else
  85.   {
  86.     $edit_profile = $_SESSION['user'];
  87.     $sql= "UPDATE User SET user_info='$info', password='$password', salt='$salt', sex='$sex', age='$age', sports='$sport' WHERE user_id = $edit_profile";
  88.   }
  89. if($con->query($sql)===TRUE)
  90.     {
  91.   echo("Information updated");
  92.     }
  93. else
  94.     {
  95.   echo"Error:".$sql."<br>".$con->error;
  96.     }
  97. }
  98.  
  99.         $user = $_SESSION['user'];
  100.         $bild = $con->query("SELECT image FROM user WHERE 'user_id' = '$user'")
  101.             or die("query failed");
  102.        
  103.        if ($bild != 0)
  104.        {
  105.         while ($bilder = $bild->fetch_assoc())
  106.         {
  107.             echo "<div id='img_div'>";
  108.             echo "<img src='pictures/".$bilder['image']."'>";
  109.             echo "</div>";
  110.        
  111.         }  
  112.            $bild->free();
  113.        }
  114.        
  115.     $currentuser = $_SESSION['user'];
  116.     $matches = $con->query("SELECT * FROM User WHERE user_id = '$currentuser'")
  117.         or die("query failed");
  118.  
  119.     if ($matches != 0)
  120.       {
  121.         while ($matchArray = $matches->fetch_assoc())
  122.           {
  123.  
  124.         echo "<div class=\"profile\" align=\"center\">";
  125.         echo "<b>Email:</b> ". $matchArray['email'];
  126.         echo "<br /><b>User information:</b> ".$matchArray['user_info'];
  127.         echo "<br /><b>Gender:</b> ".$matchArray['sex'];
  128.         echo "<br /><b>Age:</b> ".$matchArray['age'];
  129.         echo "<br /><b>Sport:</b> ".$matchArray['sports'];
  130.         echo "</div>";
  131.  
  132.           }
  133.          
  134.           $matches->free();
  135.       }
  136. ?>
  137. <a href="profile_edit.php" class="button">Edit profile.</a>
  138.     </body>
  139.     <meta charset="utf-8">
  140.     <link rel="stylesheet" href="projekt.css"/>
  141.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  142.     <script src="projekt.js" ></script>
  143. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement