Jump to content

PHP beginner- Want to redirect to top of page


PHP_CHILD

Recommended Posts

I now am missing something silly here.. but can't figure

out....If someone has time, pls tell me where is tat am doing wrong??

 

 

<?php

$a;

if($a)

{

echo "want to use header to redirect";

}

?>

<html>

<form action="aa.php" method="post">

 

<input type="submit" value="submit">

</form>

</html>

 

<?php

if(condition_true_after_submit_pressed)

{

echo "okkk";

$a=true;

}

 

?>

The only thing possibly resembling a question that you've said is about how to redirect to the top of the page.

To do that... redirect to the page. Don't do anything special. It's just a normal redirect.

The only thing possibly resembling a question that you've said is about how to redirect to the top of the page.

To do that... redirect to the page. Don't do anything special. It's just a normal redirect.

thank for d respones..

But

this is my code....

 

<?php

 

if($a)

{

echo "want to use header to redirect";

}

?>

<html>

<form action="aa.php" method="post">

 

<input type="submit" value="submit" name="submit">

</form>

</html>

 

<?php

if((isset($_POST['submit']))&& ($_POST['submit']))

{

echo "okkk";

$a=true;

}

 

?>

can u tell me why doesn't it echos??? echo "want to use header to redirect";... it echos "okkk"... does this have anything2 do with variables...???Help plssss....

Well, as far as I can tell you expect the $a=true you have at the bottom of the script to affect the if($a) you have at the top of the script. Causality doesn't work that way: define the variable first, use the variable second.

Well, as far as I can tell you expect the $a=true you have at the bottom of the script to affect the if($a) you have at the top of the script. Causality doesn't work that way: define the variable first, use the variable second.

ok so let me tell u want am tryin to do.. i have a submit form, which when clicked must be directed to another page. As i know, headers is placed before any output/html stms, i kept it at the top. To be executed.. Is der any other way to solve my problems.. Manys thanks for d responses....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.