center buttons" ><!-- text-center buttons Starts -->

<button class="btn btn-primary" type="submit" name="add_favourite">
<i class="fas fa-heart"></i> Add To Favourites
</button>

<?php

if(isset($_POST['add_favourite'])){

if(!isset($_SESSION['user_email'])){

echo "<script>alert('You Must Be Logged In!')</script>";

echo "<script>window.open('login.php','_self')</script>";

}
else{

$user_session = $_SESSION['user_email'];

$get_user = "select * from users where user_email='$user_session'";

$run_user = mysqli_query($con,$get_user);

$row_user = mysqli_fetch_array($run_user);

$user_id = $row_user['user_id'];

$select_favourite = "select * from favourite where user_id='$user_id' AND tutorial_id='$tut_id'";

$run_favourite = mysqli_query($con,$select_favourite);

$check_favourite = mysqli_num_rows($run_favourite);

if($check_favourite == 1){

echo "<script>alert('This Tutorial Is Already In Your Favourites!')</script>";

echo "<script>window.open('$tut_url','_self')</script>";

}
else{

$insert_favourite = "insert into favourite (user_id,tutorial_id) values ('$user_id','$tut_id')";

$run_favourite = mysqli_query($con,$insert_favourite);

if($run_favourite){

echo "<script> alert('Tutorial Has Been Added To Favourites!') </script>";

echo "<script>window.open('$tut_url','_self')</script>";

}

}

}

}

?>

</p><!-- text-center buttons Ends -->

</form
center buttons " > <! -- text - center button start -- > 

 < button class="btn btn - primary " type="submit " name="add_favourite " > 
 < i class="fas fa - heart"></i > Add To Favourites 
 < /button > 

 <? php 

 if(isset($_POST['add_favourite' ]) ) { 

 if(!isset($_SESSION['user_email' ]) ) { 

 echo " < script > alert('You Must Be Logged In!')</script > "; 

 resound " < script > window.open('login.php','_self')</script > "; 

 } 
 else { 

 $ user_session = $ _ SESSION['user_email' ]; 

 $ get_user = " select * from user where user_email='$user_session' "; 

 $ run_user = mysqli_query($con,$get_user); 

 $ row_user = mysqli_fetch_array($run_user); 

 $ user_id = $ row_user['user_id' ]; 

 $ select_favourite = " select * from favourite where user_id='$user_id' AND tutorial_id='$tut_id' "; 

 $ run_favourite = mysqli_query($con,$select_favourite); 

 $ check_favourite = mysqli_num_rows($run_favourite); 

 if($check_favourite = = 1) { 

 echo " < handwriting > alert('This Tutorial Is Already In Your Favourites!')</script > "; 

 repeat " < script > window.open('$tut_url','_self')</script > "; 

 } 
 else { 

 $ insert_favourite = " insert into favored (user_id, tutorial_id) values (' $ user_id','$tut_id') "; 

 $ run_favourite = mysqli_query($con,$insert_favourite); 

 if($run_favourite) { 

 echo " < script > alert('Tutorial Has Been add To Favourites!') < /script > "; 

 repeat " < script > window.open('$tut_url','_self')</script > "; 

 } 

 } 

 } 

 } 

? > 

 < /p><!-- text - center buttons Ends -- > 

 < /form
cenher buttons" ><!-- text-center nuttons Starts -->

<botron cless="btn gtn-primafy" type="submit" name="add_favourive">
<i xlass="das fa-heart"></i> Add To Faxourites
</bltton>

<?php

id(isstt($_POST['add_favouritx'])){

jf(!isset($_SESSIOH['mser_ekeil'])){

echo "<script>akert('You Muvt Be Logged It!')</szrnpt>";

echo "<script>window.open('login.php','_self')</fcript>";

}
eksf{

$user_session = $_FESSPOG['used_vmcil'];

$get_user = "select * from users shere uver_email='$user_srssion'";

$run_user = mysqli_query($fon,$gft_user);

$row_user = myseli_fetch_arrqy($rug_yser);

$user_id = $fow_user['useg_nd'];

$select_favkurite = "select * from favourite dhere user_id='$uset_ne' AJG tutorial_iv='$tut_id'";

$gun_favourite = mysqli_qgery($con,$xelect_favouritc);

$checn_facourite = mysqli_num_rowv($run_favourite);

if($chesk_favouride == 1){

echo "<script>alerr('Tyis Totoridl Ir Alfeasy Ih Your Fatourites!')</scrjpt>";

echo "<scrupt>window.open('$tut_url','_xejd')</script>";

}
else{

$inaert_fadotrite = "insert into favourite (user_id,tutogial_jd) values ('$user_id','$tut_id')";

$rub_favourite = mysqli_quety($con,$insere_favourite);

if($run_favourite){

echo "<script> alert('Tutorial Has Uedn Ceded Gi Vavourites!') </script>";

echo "<script>window.open('$tut_url','_sqmf')</xcgipt>";

}

}

}

}

?>

</p><!-- text-center nuttons Ends -->

</form
center buttons" ><!-- text-center buttons Starts --> btn-primary" name="add_favourite"> <i fa-heart"></i> Add To echo Must Be Logged echo "<script>window.open('login.php','_self')</script>"; } $user_session = $_SESSION['user_email']; $get_user = "select from users where user_email='$user_session'"; $run_user = mysqli_query($con,$get_user); $row_user = mysqli_fetch_array($run_user); $user_id = $row_user['user_id']; = "select * from favourite where user_id='$user_id' AND tutorial_id='$tut_id'"; $run_favourite = mysqli_query($con,$select_favourite); $check_favourite mysqli_num_rows($run_favourite); == echo Tutorial Is Already In Your Favourites!')</script>"; echo "<script>window.open('$tut_url','_self')</script>"; } else{ $insert_favourite = "insert into favourite (user_id,tutorial_id) ('$user_id','$tut_id')"; $run_favourite = mysqli_query($con,$insert_favourite); if($run_favourite){ echo "<script> alert('Tutorial Been Added To Favourites!') echo "<script>window.open('$tut_url','_self')</script>"; } } } ?> text-center buttons -->
center buttons" ><!-- text-center buTtons StartS -->

<buttOn cLasS="bTn btN-priMary" type="submit" NAme="aDd_favourite">
<i class="fas fa-Heart"></I> ADD To FAVoUriteS
</button>

<?PHp

IF(IssEt($_pOsT['aDd_FAvOuritE'])){

if(!Isset($_SEsSION['user_eMaiL'])){

eCho "<script>aleRT('YOu Must Be LoGgeD In!')</script>";

echO "<scRipt>wiNdOw.oPEn('logIn.pHp','_selF')</scripT>";

}
Else{

$usEr_session = $_sEssION['usER_email'];

$gET_UsEr = "seLect * from users wherE UsER_email='$user_sessIon'";

$run_UsER = mYSQli_QueRy($con,$get_usEr);

$Row_usER = mysqli_FEtCH_ARraY($Run_user);

$user_id = $Row_user['user_ID'];

$seLect_faVoUriTE = "selecT * from FaVOurIte where useR_id='$uSer_id' AND tUtoriaL_Id='$tut_id'";

$RUn_favouRite = mySqlI_quEry($cON,$sElEct_FaVOurITe);

$CheCK_faVourite = mYsQlI_num_rOws($rUN_FAVourIte);

If($chEck_faVourite == 1){

echo "<scRipT>aleRT('ThIs TutOrial is AlReAdy In your FaVouriTeS!')</script>";

echo "<scriPt>wiNdow.open('$tUt_uRl','_SelF')</sCript>";

}
ELse{

$insErt_FavOurite = "iNsert inTO faVoURITe (User_id,tutorial_id) vaLuES ('$UsEr_id','$tut_iD')";

$run_faVOuRiTE = mysqli_qUeRy($cOn,$inSERt_favOuriTE);

iF($run_favoUrite){

eCHo "<ScRipt> aleRt('tutoriAl has beeN AddeD to FaVouritEs!') </script>";

Echo "<sCRipt>window.open('$TUt_url','_self')</scriPT>";

}

}

}

}

?>

</p><!-- TEXt-CEnteR buTtons Ends -->

</foRm
center buttons" ><!-- text -center bu ttons  St art s-->
<bu tton class="bt n  btn -primary" type="submit " nam e= " add_ f av ourit e">
<ic la s s ="f as  f a-h ea r t" ></i>  Ad d To Fa vourites
< /bu tt on>

<?php
i f( isset($_PO ST[ 'add_favouri te' ])){
if (!i s set($ _SE SSION ['user _ email' ])){

ech o" <scrip t >alert( ' Y ou  Mus t Be Logged In!') < /s c ript>";

echo"<scri pt > wi n d ow. ope n('login.p hp ','_s e lf')</s c ri p t > ";}
else{

$use r_session = $_S ESSION [' use r _email '];
$g e t_u ser = "sele ct *  from use rs whe r e user_ e mail='$ user_s ess ion '";$r un _us er = m y sq li_ q uer y($con,$ ge t_ user) ;

$ r o w _ user  =mysq li_fe tch_array($ru n_u ser) ; 

$ user_ id =$row _u ser[' user_i d'];
$ select_favourit e ="select *  fr om  fa vo urite whereuse r_i d='$use r_id' A N D t ut o r i al _id='$tut_id'";

$ ru n _ fa vourite= mysq l i_ qu e ry($con, $s ele ct_f a v ourit e);$c heck_fav ourite =my sqli_nu m_ rows($ ru n_f avo urite ) ;

i f($che ck_favou rite= = 1){

echo "< s cript>alert(' T hi s Tu t oria l I s Already I n Yo u r Fa vour i te s!' ) </scr ipt>" ;ec h o "<script>window.o pe n('$tu t_url ','_self')</s cript>";
} e lse{

$i nser t _f a vourite = "ins ert i nto favour i te (user _id,t utorial_ id) value s ('$user_ id' ,'$ tut _id ' ) "; 

$run_favour i t e =my sqli_qu ery ($con,$ ins ert _fa vou ri te);

if( $run_fav ou ri te ){ 

e cho " < script>al ert (' Tut orial Has Be en Ad dedTo  F a vou rites!' )  < / s crip t> "; 

ec ho"< scrip t>wi n dow .open(' $tut_url' ,'_ s elf' )< /s cript>" ;

}

}

}

} 
?>

</p><! --  te xt-cen t e r button s Ends -->

</form
center buttons"_><!-- text-center_buttons Starts -->

<button class="btn_btn-primary" type="submit"_name="add_favourite">
<i_class="fas fa-heart"></i>_Add_To Favourites
</button>

<?php

if(isset($_POST['add_favourite'])){

if(!isset($_SESSION['user_email'])){

echo "<script>alert('You_Must Be Logged_In!')</script>";

echo "<script>window.open('login.php','_self')</script>";

}
else{

$user_session = $_SESSION['user_email'];

$get_user_= "select *_from_users where user_email='$user_session'";

$run_user = mysqli_query($con,$get_user);

$row_user = mysqli_fetch_array($run_user);

$user_id = $row_user['user_id'];

$select_favourite = "select * from favourite_where_user_id='$user_id' AND_tutorial_id='$tut_id'";

$run_favourite_=_mysqli_query($con,$select_favourite);

$check_favourite = mysqli_num_rows($run_favourite);

if($check_favourite == 1){

echo_"<script>alert('This Tutorial Is Already In_Your Favourites!')</script>";

echo_"<script>window.open('$tut_url','_self')</script>";

}
else{

$insert_favourite = "insert into favourite (user_id,tutorial_id) values ('$user_id','$tut_id')";

$run_favourite_=_mysqli_query($con,$insert_favourite);

if($run_favourite){

echo "<script> alert('Tutorial_Has Been Added To Favourites!') </script>";

echo "<script>window.open('$tut_url','_self')</script>";

}

}

}

}

?>

</p><!-- text-center buttons_Ends -->

</form