Re: JavaScript vs. Header redirect

From: Date: Wed, 22 May 2002 02:10:18 +0000
Subject: Re: JavaScript vs. Header redirect
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98675@lists.php.net to get a copy of this message
the below code should work, although, you've posted pseudo code, so i can't check it for any errors. if you don't print anything to the screen (including error messages, white space, etc), header() will work. be aware that any implementation of javascript will be limited to clients that have javascript turned on, or even available. i wouldn't be basing something as simple as a redirect on JS, because of the implications... i'd be getting the code right on the server. justin on 22/05/02 11:19 AM, Hunter Vaughn (hkv@efn.org) wrote: > Is there any reason I can't just use a JavaScript redirect from a PHP login > handling script since I can't seem to get the header("Location: URL"); > function to work? Any security concerns or anything else? As far as I can > tell, all calls to header fail as soon as I attain variables based on a POST > submission. See example below. > > <? > $username = $_POST[username]; > $password = $_POST[password]; > > if(some username/password format verification) { > query the database > if($password matches pass in database) { > session_start(); > $email = $Row[0]; > $memberID = $Row[1]; > session_register('email'); > session_register('memberID'); > //header("Location: URL"); This doesn't work. > print("<script language=\"JavaScript\">window.location = > \"‚ > ;\*¶ŸY:[-Ãk+Сhttp://depts.washington.edu/bionano/HTML/letsboogie22.html\";</script>"); > exit; > } > else { > print("That didn't work..."); > } > } > else { > print("Please enter your username & password."); > } > ?> > >

« previous php.general (#98675) next »