-1
simplified twitter replica
ERROR
Warning: Cannot Modify header information - headers already sent by (output Started at /Storage/ssd2/125/17032125/public_html/follow.php:3) in /Storage/ssd2/125/17032125/public_html/follow.php on line 26
Explanation of functionality
If I click on following any user in the.php publishing file is redirected by action to another file (follow.php) with get parameter and the following user id.
If the parameter is from, it activates a follow function, and if not it stops following (with a query between two id "follower_id and user_id").
Recurrent error
when I click on follow happens header error 1. However functions with database continue to function normally and the user follows and stops following and only appears if you go back to page.
follow.php
<?php
session_start();
print "<pre>";
print_r($_SESSION);
include_once("header.php");
include_once("functions.php");
$id = $_GET['id'];
$do = $_GET['do'];
switch ($do){
case "follow":
follow_user($_SESSION['userid'],$id, $db);
//$msg = "You have followed a user!";
break;
case "unfollow":
unfollow_user($_SESSION['userid'],$id, $db);
//$msg = "You have unfollowed a user!";
break;
}
//$_SESSION['message'] = $msg;
// futuramente imprimir com um framework uma caixa na tela dizendo q esta seguindo
header("location: publicacoes.php");
?>
Excerpt from the publications.php
<?php
// imprime os usuários e se quer seguir ou não
$users = show_users($db);
$following = following($_SESSION['userid'], $db);
foreach ($users as $key => $user) {
print "<p class=\"nome-perfil-comentario\">". $user ."</p>";
if (in_array($key, $following)){
$_GET['id'] = $key;
$_GET['do'] = 'follow';
print"<a nome=\"follow\" href=\"follow.php?id=$key&do=unfollow\" class=\"botao-seguir w-inline-block\">
<p class=\"seguir\"><small>Não seguir</small></p>
</a>";
} else {
print"<a href=\"follow.php?id=$key&do=follow\" class=\"botao-seguir w-inline-block\">
<p class=\"seguir\"><small>Seguir</small></p>
</a>";
}
}
?>