/    Sign up×
Community /Pin to ProfileBookmark

reload a page

is there another way to reload a page than this :
header(“Location:”.$_SERVER[‘PHP_SELF’].”?id=1&Section=”.$_GET[“Section”]);

Cause it say the header is already sent and I don’t think i can call it before any output

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@JonaApr 27.2004 — [code=php]
<a href="<?php echo ($_SERVER["PHP_SELF"] ."id=1&Section=". $_GET["Section"]); ?>" title="Reload the current page.">[Reload]</a>
[/code]
Copy linkTweet thisAlerts:
@SamKookauthorApr 27.2004 — and if I want to reload it automatically?
Copy linkTweet thisAlerts:
@JonaApr 27.2004 — [font=arial]Why would you want to output something to the browser if you are going to redirect it, anyway? Why not just redirect it? Then you wouldn't have to worry about your headers problem. If you want a timed redirection, use JavaScript.[/font]
Copy linkTweet thisAlerts:
@SamKookauthorApr 27.2004 — and if I don't want to use javascript...

i guess i'm screw up
Copy linkTweet thisAlerts:
@violent_jApr 27.2004 — you can use a meta-tag (place it in the <HEAD> section) like this:

<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">

which means that the page redirects to http://www.some.org/some.html within 3 seconds

grtz
Copy linkTweet thisAlerts:
@JonaApr 27.2004 — [font=arial]Violent J, you should not use META refreshes.[/font]

[i]From the W3C WCAG 1.0 Guidelines, section 7.4[/i]

[b]Until user agents provide the ability to stop the refresh, do not create periodically auto-refreshing pages.[/b]

[i]From the W3C WCAG 1.0 Guidelines, section 7.5[/i]

[b]Until user agents provide the ability to stop auto-redirect, do not use markup to redirect pages automatically. Instead, configure the server to perform redirects.[/b][/quote]


[font=arial]Edit: The reason it is valid to use JavaScript for redirection, although not rely on it, is because it is not markup (the META refresh tag is), and it can be disabled.[/font]
Copy linkTweet thisAlerts:
@SamKookauthorApr 27.2004 — Is there a way to call the function EffacerImage before any output whe i have to click on a button?

Here is my code(importants parts are in bold)
[code]
<?php
$db = mysql_connect("localhost", "Sam")
or die ("Impossible de se connecter à la base de données");
mysql_select_db("melville",$db)
or die ("Impossible de sélectionner la base de données");

if (isset($_COOKIE["Login"]))
{
include "VerifierLogin.php";
}

[B]Function EffacerImage()
{
header("location:".$_SERVER['PHP_SELF']."?id=1&section=".$_GET["Section"]);
}[/B]
?>
<html>
<head>
<title>Voir les photos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<?php
$id = $_GET["id"];
$Section = $_GET["Section"];
$Num = 0;
$iCtr = 1;
$iNext = 1;
$iPrev = 1;
$QuerySection = "SELECT * FROM configimages WHERE Section="".$Section.""";

$result2 = mysql_query($QuerySection,$db);

if($myrow2 = mysql_fetch_array($result2))
{
echo "<style type=text/css>";
echo "<!--";
echo "body {";
printf(" background-color: %s;",$myrow2["CouleurBack"]);
printf(" background-image: url(%s);",$myrow2["ImageBack"]);
echo "}";
printf(".style1 {font-size: %spx;color: %s}",$myrow2["SizeTitre"],$myrow2["CouleurTitre"]);
printf(".style2 {font-size: %spx;color: %s}",$myrow2["SizeTexte"],$myrow2["CouleurTexte"]);
echo "-->";
echo "</style>";
}
?>

</head>
<body>
<?php
$QueryImages = "SELECT * FROM ".$myrow2["NomTable"];

if ($id == "")
{
$id = "1";
}

$result = mysql_query($QueryImages,$db);
$Num = mysql_num_rows($result);

if($myrow = mysql_fetch_array($result))
{
//Se positionner sur la bonne image
for($iCtr=1; $iCtr <$id; $iCtr++)
{
$myrow = mysql_fetch_array($result);
}

//Début de l'affichage
printf("<p align="center" class="style1">%s</p>",$myrow2["Titre"]);
echo"<p align="center" class="style2">";

if ($id < $Num && $id > 1)
{
$iNext = 1;
$iPrev = 1;
}
elseif ($Num == 1)
{
$iNext = 0;
$iPrev = 0;
$id = 1;
}
elseif ($id <= 1)
{
$iNext = 1;
$iPrev = 0;
$id = 1;
}
elseif ($id >= $Num)
{
$iNext = 0;
$iPrev = 1;
$id = $Num;
}

printf("<a href="%s?id=%s&Section=%s"><img src="%s" width="42" height="48" border="0"></a>",
$_SERVER['PHP_SELF'],$id-$iPrev,$Section,$myrow2["FlecheG"]);

printf("<a href="%s?id=%s&Section=%s"><img src="%s" width="42" height="48" border="0"></a><br />",
$_SERVER['PHP_SELF'],$id+$iNext,$Section,$myrow2["FlecheD"]);

printf("image %s/%s",$id,$Num);
echo"</p>";

echo"<table width="200" border="1" align="center">";

printf("<tr><td><P ALIGN="center"><a><IMG SRC="%s" BORDER="0" NAME="slide"></a></P></td></tr>",
$myrow["Images"]);

echo"</table>";

[B] //Section admin pour effacer les photos
if (isset($_GLOBALS['kookie']))
{
$Action = EffacerImage();
printf("<form name="Delete" method="post" enctype="multipart/form-data" action="%s">",$Action);
echo "<p align="center">";
echo "<input name="delete" type="submit" value="effacer">";
echo "</p>";
echo "</form>";
}[/B]

}
else
{
echo"<br /><p align=center>Désolé, il n'y a aucunes images pour cette section.</p>";
}
?>
</body>
</html>
Copy linkTweet thisAlerts:
@JonaApr 27.2004 — [font=arial]It looks like your EffacerImage function is not returning anything, so the output to the form wouldn't be correct. You should use a return statement.[/font]

[code=php]
function EffacerImage()
{
$default = "1"; # default section
if(isset($_GET["Section"])) {
return ($_SERVER["PHP_SELF"]."?id=1&Section=". $_GET["Section"]);
}
else {
return ($_SERVER["PHP_SELF"]."?id=1&Section=". $default);
}
}
[/code]
Copy linkTweet thisAlerts:
@SamKookauthorApr 27.2004 — Your right and it solved my problem.

Thanks
Copy linkTweet thisAlerts:
@violent_jApr 27.2004 — hmm .. i've never heard about these accessibility guide lines, but on this forum it seems like a holy god !

but i'll take it in consideration ?

grtz

[offtopic]

@Jona: Nice sig ?

[/offtopic]
Copy linkTweet thisAlerts:
@JonaApr 27.2004 — [font=arial]SamKook, I'm glad the problem has been resolved. ?

Violent J, many people have not heard of accessibility. In these forums, many have been taught to design with CSS and semantic markup, rather than using tables for layout. This is also in the [url=http://www.w3.org/TR/WCAG10/]Web Content Accessibility (WCAG) 1.0 guidelines[/url]. An accessible Web site is one that anyone can access, whether blind or dyslexic or whatever.

Also, thanks for the comment on the signature. ? Have you checked out my links page? You should find many of those links very helpful, as almost all of them will agree with or aggressively promote accessibility.[/font]
×

Success!

Help @SamKook spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...