Jump to content

About reloading


kv79

Recommended Posts

I try with forms like this

echo "  <form action="withlogin.php">  ";echo "  </form>								  ";

but ,show me some error Is reason why i need this is because i want to make my own forum ,so if you can help in other way please do it .Thank you for your interesting in my message .

Link to comment
Share on other sites

Be careful with your quotes! You need to escape them with a backslash ("\") or use single quotes instead. For example:

echo "  <form action=\"withlogin.php\">  ";echo "  </form> ";

or

echo '  <form action="withlogin.php">  ';echo "  </form> ";

Link to comment
Share on other sites

Hi all,I want to open page
$number=1; if($number==1) //i need help over here

I do not know how to load some other page if number is 1.

I'd love to help, but I really don't understand the question. Maybe some more information?
Link to comment
Share on other sites

When dealing with strings, you have to escape certain characters. If you use ' (single quote) you will have to add a \ to it, \', but with a " (double) you will have to escape $, \, ", etc. because they are "special characters", start of variables, etc.http://www.php.net/manual/en/language.type...g.syntax.doubleIt's usually a good idea to surround your code with { } when using if conditionals and loops.If you want to add the code from another file from your computer

<?php  $number=1;  if ($number==1) {	include('file.php');  }?>

Link to comment
Share on other sites

I'm not sure what it is you want, but if you want the user to be sent to another page U can use:

header("location:../page2.php");

Link to comment
Share on other sites

-> boen_robot Oh thanks I solved that error but not my hole problem . -> Deirdre's Dad I was talking about for example:I have a page in PHP and if user typed a correct name he will get a page for true name but if user typed a wrong name he will get a page for false name .-> mma_fighter123Thank is very helpful because I just got all contain from my other page .-> Zaph Thanks for trying , because this is header and i just try to use this header('Location: http://www.msn.com/'); and they did not give an example with real acting so I will suppose here I go -> http://www.php.net/headerheader() must be called before any actual output is sent ... ,they mean that i must at least write 2 code like JS or any other scripting language who will change the style or acting page or look or contain page (for example background ) and on my wish the will change .Please tell me if all of this my imagination .For all good people who answer my post , thank you .

Link to comment
Share on other sites

Err I'm confused by your writing :) are you thinking of something like

$number=1;if($number==1)   header("location:somewhere");} else {   header("location:somewhereelse");}

header() must be called before any actual output is sent ... ,they mean that i must at least write 2 code like JS or any other scripting language who will change the style or acting page or look or contain page (for example background ) and on my wish the will change .
That means that you can't have any HTML or other echoing before the header() call.
Link to comment
Share on other sites

header isn't a tag, it's a function in PHP. It doesn't create an HTML tag either, it creates an HTTP header with whatever you want. In this case, you want a location header to tell the browser to go to a different URL. If you use something like Firebug or Proxomitron where you can look at the headers going in and out then you can write whatever headers you want and see them in the browser's request. You also don't need anything in Javascript or anything else to use this.

<?phpif ($_GET['number'] == 1){  header("Location: page1.php");  exit();}if ($_GET['number'] == 2){  header("Location: page2.php");  exit();}if ($_GET['number'] == 3){  header("Location: page3.php");  exit();}echo "<a href=\"?number=1\">page 1</a> <a href=\"?number=2\">page 2</a> <a href=\"?number=3\">page 3</a> ";?>

Link to comment
Share on other sites

-> justsomeguy then you can write whatever headers you want and see them in the browser's requestOk, I just copy paste your code and again same error Warning: Cannot modify header information - headers already sent by I installed a Firebug addition for Firefox and I do not see any headers in page source.What is going on ? Can somebody else try to copy paste his code to see is it same error? Thanks advance .

Link to comment
Share on other sites

You get that error if you send output before using header, you have to use header before you send anything else. Once you send any output at all the headers get sent, so you need to send all headers before you start the output. More information here:http://w3schools.invisionzone.com/index.ph...ost&p=96607

Link to comment
Share on other sites

s i g hListen, the code isn't working because of where you chose to put it. You put it after output had already been sent. Read the post I linked to, it talks about using the error message to find where the output is. If you paste what I wrote as its own PHP document you will find that it works perfectly fine.And please stop accusing us of not knowing what we're doing, that's the second time you've done that now. I'm a professional programmer with a university degree and 5 years of professional experience, I know how to use a header. I'm trying to teach you, so it's you that doesn't know what you're doing. Please read what I'm telling you to read and ask questions if you have them, and I will do my best to answer them.

Link to comment
Share on other sites

You are a Just a Fine guy professional programmer with a university degree and 5 years of professional experience, I know how to use a header .I trust you ,you know how to use header , but that did not solve my problem .I read your link and it was no useful to me because your explanation does not have a code reflection .

Link to comment
Share on other sites

The explanation isn't about the code, the explanation is about the error message that you get. It tells you specifically where the output is that causes the warning. Since you haven't posted your error message or the code that you're using, then there's not a lot I can do.

Link to comment
Share on other sites

This is for page1.php -> I also changed a name of page1.php into my created page .Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\php\index.php:11) in C:\xampp\htdocs\php\index.php on line 17This is for page2.php Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\php\index.php:11) in C:\xampp\htdocs\php\index.php on line 23This is for page3.php Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\php\index.php:11) in C:\xampp\htdocs\php\index.php on line 29

Link to comment
Share on other sites

This is the important part:output started at C:\xampp\htdocs\php\index.php:11That means that there was some output sent on line 11 of /php/index.php. You need to move the call to header before that. If you try to use header after you start output you'll get the warning, so you need to restructure your page so that all of the PHP processing happens before sending any output (if you're redirecting then you don't need to send any output anyway). e.g.:

<?php// ALL PHP processing code goes here, before anything else?><html>...

You can always set flags or variables to output information later on in the page.

<?php$msg = "";if (something){  $msg = "first message";  // don't echo, just set the variable}else{  $msg = "second message";}if (something else){  header("Location: somewhere");  exit();}?><html>...<div id="message"><?php echo $msg; /* now print it */ ?></div>

Link to comment
Share on other sites

Even

 <?phpheader("location:page.php");?>

will not be correct, as there is a newline (which is output) before the PHP tag.

Link to comment
Share on other sites

-> justsomeguy (if you're redirecting then you don't need to send any output anyway)And I did use it for redirecting .The code working and it was very useful .Thank you for your effort of reading , understanding , life time ,all other stuff that I did not noticed .-> Synook Thank you very much for your research .

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...