woolyg Posted January 15, 2008 Share Posted January 15, 2008 Hi all, I'm having difficulties with urlencode() - can anyone help? What I'm trying to do is use an HTML refresh on one page (log_me_in.php) to open another (main.php?badlogin=true), but it just won't work for me. Here is the code from log_me_in.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <?php $str = "true"; $string = urlencode($str); ?> <meta http-equiv="refresh" content="0;URL=main.php?badlogin=<?php echo $string; ?>" /> <title>Bad login - Redirecting...</title> </head> <body> </body> </html> ..and here is the code for main.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Main</title> </head> <body> <?php echo $_GET['badlogin']; ?> </body> </html> On main.php, $_GET['badlogin'] is not displaying. I understand (from reading prior issues like this) that with standard characters it shouldn't be necessary to use urlencode() in the first place, but I've been told by my web host that it is necessary to use. Can anyone help? All input appreciated. Woolyg. Quote Link to comment Share on other sites More sharing options...
KrisNz Posted January 15, 2008 Share Posted January 15, 2008 Why cant you just send a header instead i.e - before any html have something like if ($login == "bad") { header("location:main.php?login=bad"); exit; } urlencode will only affect strings with non alpha-numeric characters in them. Btw, meta-refresh is deprecated. meta_refresh on wikipedia Quote Link to comment Share on other sites More sharing options...
woolyg Posted January 15, 2008 Author Share Posted January 15, 2008 I'll change over the redirection style this evening, thanks for the info. Hopefully it'll work. WoolyG Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.