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;

}

 

?>

Edited by PHP_CHILD
Link to comment
Share on other sites

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....

Edited by PHP_CHILD
Link to comment
Share on other sites

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....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.