Jump to content

Redirect not working in my code, why not?


Mythic Fr0st

Recommended Posts

This is it...

its suppost to redirect to http://localhost/Test/Signup.php?error=u2s

[code]<?php
if ($_GET['error'] == 'u2s')
{   
echo '<font color="red" size="3"><i>Your username requires atleast 5 characters</i></font>';
}
?>[/code]


[code]<?php
$minLength=5;
function checkLength1($user, $minLength)
{
      if (strlen($user) < $minLength)
      {
              return false;
      }
      else
      {
              return true;
      }
}


if (!checkLength1($_POST['user'], 4))
{
    header("location: http://localhost/Test/Signup.php?error=u2s");
}
?>[/code]

the header thing suppost to redirect to that error page...

But I get these errors too
[code]
Notice: Undefined index: error in c:\program files\easyphp1-8\www\test\signup.php on line 22

Notice: Undefined index: error in c:\program files\easyphp1-8\www\test\signup.php on line 28

Notice: Undefined index: error in c:\program files\easyphp1-8\www\test\signup.php on line 34

Notice: Undefined index: error in c:\program files\easyphp1-8\www\test\signup.php on line 40

Notice: Undefined index: error in c:\program files\easyphp1-8\www\test\signup.php on line 46[/code]

AND these
[code]
Notice: Undefined index: user in c:\program files\easyphp1-8\www\test\signup.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\test\signup.php:4) in c:\program files\easyphp1-8\www\test\signup.php on line 106

Notice: Undefined index: pw1 in c:\program files\easyphp1-8\www\test\signup.php on line 124

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\test\signup.php:4) in c:\program files\easyphp1-8\www\test\signup.php on line 126

Notice: Undefined index: pw2 in c:\program files\easyphp1-8\www\test\signup.php on line 144

Notice: Undefined variable: pw2 in c:\program files\easyphp1-8\www\test\signup.php on line 134

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\test\signup.php:4) in c:\program files\easyphp1-8\www\test\signup.php on line 146

Notice: Undefined index: pw1 in c:\program files\easyphp1-8\www\test\signup.php on line 154

Notice: Undefined index: pw2 in c:\program files\easyphp1-8\www\test\signup.php on line 154

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\test\signup.php:4) in c:\program files\easyphp1-8\www\test\signup.php on line 163

Notice: Undefined index: email1 in c:\program files\easyphp1-8\www\test\signup.php on line 172

Notice: Undefined index: email2 in c:\program files\easyphp1-8\www\test\signup.php on line 172

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\test\signup.php:4) in c:\program files\easyphp1-8\www\test\signup.php on line 181[/code]

why cant I modify header info, whats it mean?, and how do I fix this
Link to comment
https://forums.phpfreaks.com/topic/29196-redirect-not-working-in-my-code-why-not/
Share on other sites

you can only use the header function at the very top of your source code us this instead:
[code]
function Redirect($time, $topage) {

echo "<meta http-equiv=\"refresh\" content=\"{$time}; url={$topage}\" /> ";

}
[/code]

and the undefined index one means that an array contains an index name that doesn't exists.
I know that, but I cant change that, because like, they dont exist yet, or something i dunno -.-

Could you do me a big favour, and err

just put it into text, I dont understand that,

I have other things, and I dont know if to delete them, or what i dunno O_O
I know, but look at this for example, I cant remove em


[code]mail($_POST['email1'],$subject,$msg,$headers);[/code] the ['email1'] doesnt exist on this page

but on signup page, when you click signup, it goes here, and email's to you, email1 is the name, of the text box, that they put their e-mail in, how else can I do it, so I dont have the "Notice undefined index thing", I got no idea, considering I have 30 on my homepage ( can these be seen by others ?! )

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.