diff --git a/page_profile/favorite.php b/page_profile/favorite.php
new file mode 100644
index 0000000000000000000000000000000000000000..f50fb0fe4f1c21573ab6e74e5404deedcda14bb8
--- /dev/null
+++ b/page_profile/favorite.php
@@ -0,0 +1,46 @@
+<?php
+session_start();
+
+// initializing variables
+$username = $_SESSION['username'];
+$user_id = $_SESSION['user_id'];
+$twitter_fav = $_SESSION['twitter']? $_SESSION['twitter'] : array();
+$youtube_fav = $_SESSION['youtube']? $_SESSION['youtube'] : array();
+$errors = array();
+
+// connect to the database
+$db = mysqli_connect('localhost', 'root', 'root', 'data');
+
+if (mysqli_connect_errno()) {
+  printf("Echec de la connexion: %s\n", mysqli_connect_error());
+  exit();
+}
+// REGISTER USER
+if (isset($_POST['submit'])) {
+  // receive all input values from the form
+  $fav_type = $_POST['type'];
+  $new_sub = $_POST['sub'];
+  $retour = 'location: profil.php?id='.$new_sub.'&sn='.$fav_type;
+
+  // form validation: ensure that the form is correctly filled ...
+  // by adding (array_push()) corresponding error unto $errors array
+  if (empty($fav_type)) { array_push($errors, "Fav type is required"); }
+  if (empty($new_sub)) { array_push($errors, "Name of sub is required"); }
+}
+if ($fav_type == "Twitter"){
+  array_push($twitter_fav, $new_sub);
+  $twitter = serialize($twitter_fav);
+  $favt_update_query = "UPDATE favorites SET twitter = '$twitter' WHERE userid = '$user_id'";
+  $favtres = mysqli_query($db, $favt_update_query);
+  $_SESSION['twitter'] = $twitter_fav;
+  header($retour);
+}
+if ($fav_type == "Youtube"){
+  array_push($youtube_fav, $new_sub);
+  $youtube = serialize($youtube_fav);
+  $favy_update_query = "UPDATE favorites SET youtube = '$youtube' WHERE userid = '$user_id'";
+  $favyres = mysqli_query($db, $favy_update_query);
+  $_SESSION['youtube'] = $youtube_fav;
+  header($retour);
+}
+?>
diff --git a/page_profile/profil.php b/page_profile/profil.php
index f8627e8b7fdc7030113ca90c67b9621e0185344d..84c30efc3924a08dfe114a4f95924ac74b8c68d4 100644
--- a/page_profile/profil.php
+++ b/page_profile/profil.php
@@ -7,12 +7,14 @@ session_start();
 
 if (isset($_POST['username'])) {
 	$id = getUserId($_POST['username']);
+	$sub_name = $_POST['username'];
 }
 elseif (isset($_POST['id'])) {
  	$id = $_POST['id'];
 }
 elseif (isset($_GET['username'])) {
 	$id = getUserId($_GET['username']);
+	$sub_name = $_GET['username'];
 }
 elseif (isset($_GET['id'])) {
  	$id = $_GET['id'];
@@ -33,7 +35,8 @@ elseif (isset($_GET['sn'])) {
 else {
 	echo('ERREUR');
 }
-
+$twitter_fav = $_SESSION['twitter'];
+$youtube_fav = $_SESSION['youtube'];
 //$id = $_POST['id'];
 ?>
 
@@ -56,7 +59,7 @@ else {
 -->
 
 			<div id="photoprofil">
-				<img src='<?php 
+				<img src='<?php
 					if ($socialNetwork === "Twitter") {
 						echo getUserProfileImage($id);
 					}
@@ -64,10 +67,34 @@ else {
 						echo getChannelProfileImage($id);
 					}
 					?>' alt='profile_image' style="width:100px;height:100px;"/>
+					<br/>
+					<br/>
+					<?php
+					if (!$_SESSION['username']){
+						echo '<a id="modal_trigger" href="#modal" class="text-white">Login to add to favorites</a>';
+					}
+					elseif ( in_array($id, $twitter_fav) || in_array($id, $youtube_fav) ){
+						echo '<button style="margin-left:10px">Subscribed</button>';
+					}
+					elseif ( $socialNetwork == "Twitter" || !$socialNetwork){
+						echo '<form action="favorite.php" method="post" style="margin-left:10px">
+		    			<input type="hidden" name="sub" value="'.$id.'" />
+							<input type="hidden" name="type" value="Twitter" />
+							<input type="submit" name="submit" value="Subscribe" />
+						</form>';
+				 }
+				 else{
+					 echo '<form action="favorite.php" method="post" style="margin-left:10px">
+						 <input type="hidden" name="sub" value="'.$id.'" />
+						 <input type="hidden" name="type" value="Youtube" />
+						 <input type="submit" name="submit" value="Subscribe" />
+					 </form>';
+				}
+					?>
 			</div>
 			<br/><br/>
 			<div class='flexspace' style="padding:30px 40px 0px;border-left:1px solid;width:100%;background-image: linear-gradient(to bottom right, #919df9, #93eeff);border-radius:50px">
-				<div><?php echo $socialNetwork; ?> Username <br/> <h5><?php 
+				<div><?php echo $socialNetwork; ?> Username <br/> <h5><?php
 						if ($socialNetwork === "Twitter") {
 							echo getUserScreenName($id);
 						}
@@ -75,7 +102,7 @@ else {
 							echo getChannelUsername($id);
 						}
 					?>
-					
+
 				</h5><br/></div>
 				<div>
 					<?php