redirecting back to php file
<p>following code is my php file that will list the people in my text file.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;viewlist php&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;List&lt;/h1&gt;
&lt;?php
$file = file("peoplelist.txt");
for($i=0; $i&lt;count($file); $i++)
{
  $person = explode(",", $file[$i]);
  echo "&lt;hr /&gt;";
  echo "&lt;table cellspacing=10&gt;&lt;tr&gt;&lt;td&gt;", $i+1,".", "&lt;/td&gt;";
  echo "&lt;td&gt;", $person[0], "&lt;br /&gt;";
  echo $person[1], "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
}
?&gt;
&lt;hr /&gt;
&lt;p&gt;
  &lt;a href="sortatoz.php" target="_self"&gt;Sort A-Z&lt;/a&gt;&lt;br /&gt;
  &lt;a href="sortztoa.php" target="_self"&gt;Sort Z-A&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>what i want to do is, when i click Sort A-Z link, the file called sortatoz.php will sort the list in my text file and redirect back to viewlist.php with the list in sort order.
below is my sortatoz.php:</p>

<pre><code>&lt;?php
header("Location: http://myserver/workspace/viewlist.php");
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;sort a to z&lt;/title&gt;
&lt;/head&gt;
&lt;h1&gt;List&lt;/h1&gt;
&lt;body&gt;
&lt;?php
$file = file("peoplelist.txt");
sort($file);
for($i=0; $i&lt;count($file); $i++)
{
  $person = explode(",", $file[$i]);
  echo "&lt;hr /&gt;";
  echo "&lt;table cellspacing=10&gt;&lt;tr&gt;&lt;td&gt;", $i+1,".", "&lt;/td&gt;";
  echo "&lt;td&gt;", $person[0], "&lt;br /&gt;";
  echo $person[1], "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
}
?&gt;
&lt;hr /&gt;
&lt;p&gt;
  &lt;a href="sortvisitorsascending.php" target="_self"&gt;Sort Visitors A-Z&lt;/a&gt;&lt;br /&gt;
  &lt;a href="sortvisitorsdescending.php" target="_self"&gt;Sort Visitors Z-A&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>now, when i click Sort A-Z link, it redirects back to viewlist.php...so I'm assuming the header() function is doing it's job.</p>

<p>but the problem is...it's not sorting.</p>

<p>i am very new with this, so bear with me and give me some guidance please.
what can i do to my codes to redirect back viewlist.php with sorted list?</p>

<p>thanks in advance.</p>
