"Purple Haze" <xxx@xxx.com> wrote in message
news:MuI4d.741$%06.624@newsread3.news.atl.earthlin k.net...[color=blue]
> Michael Fesser wrote:
>[color=green]
>> .oO(Purple Haze)
>>
>>[color=darkred]
>>>I guess I should have been more specfic, I need a redirect-function that
>>>can be called anytime in the script. In this instance after the script
>>>has determined that a vaild user and pass have been submitted.[/color]
>>
>>
>> Of course you can do this with header(), but you either
>>
>> * have to make sure there's no other output sent to the browser before
>> (Does the check for a valid user prints anything out?)
>>
>> or
>>
>> * have to use output buffering.
>>
>> Micha[/color]
>
> I am still unclear what your referring to, perhaps a copy of the script
> will help...
>
> <center>
> <form ACTION="login.php" name="saveform" METHOD="POST" align="center">
> <p><input NAME="username"VALUE SIZE="8" MAXLENGTH="16" tabindex="1"></p>
> <p><input type="password"name="password" size="8" tabindex="2"
> maxlength="8"></p>
> <p><input TYPE="button"NAME="FormsButton2" VALUE="Validate"
> ONCLICK="submit()" tabindex="3"style="font-family: Verdana; font-size:
> 12pt">
> </form>
> </center>
>
> <?php
> $mysql_database="login";
> $mysql_username="root";
> $mysql_password="";
> $link = mysql_connect("localhost",$mysql_username,$mysql_p assword) or die
> ("Unable to connect to SQL server");
> mysql_select_db($mysql_database,$link) or die ("Unable to select
> database");
> $username = $HTTP_POST_VARS['username'];
> $password = $HTTP_POST_VARS['password'];
>
> if (isset($password))
> {
> $qstr = "SELECT * from members where user ='$username' and pass
> ='$password'";
> $result = mysql_query($qstr);
>
> if (mysql_num_rows($result))
> {
> echo "<font color=#008000><Center><b>**Successful
> Login**</b></Center></font>";
> header("Location: http://www.example.com/");
> exit;
> }[/color]
There'e your problem right there - you have an echo statement just before
the header(). Remove the echo and the header() will work.
--
Tony Marston
http://www.tonymarston.net
[color=blue]
> else echo "<font color=#ff0000><Center><b>**Failed
> Login**</b></Center></font>";
> mysql_close();
>
> }
> else echo "<font color=#ff8000><Center><b>**No login
> attempted**</b></Center></font>";
> ?>[/color]