php - Why is redirecting to google giving a strange result? -


my code doesn't involve database or session gives perfect results

<!doctype html> <?php if(isset($_get["engine"])) { if($_get["engine"]=="google") header("location:http://www.google.com/search?q=".$_get["q"]); elseif($_get["engine"]=="yahoo") header("location:http://search.yahoo.com/search?q=".$_get["q"]); if($_get["engine"]=="bing") header("location:http://www.bing.com/search?q=".$_get["q"]); } ?> <html> <head> <title>fake search</title> </head> <body> <form action="fakesearch.php" method="get"> <input type="text" name="q" value=""/><br/> google <input type="radio" name="engine" value="google"/><br/> yahoo <input type="radio" name="engine" value="yahoo"/><br/> bing <input type="radio" name="engine" value="bing"/><br/> <input type="submit"/> </form> </body> </html> 

but when made login page , redirected home.php has same code above session variable gives me error object not found!

 requested url not found on server. link on referring page seems wrong or outdated. please inform author of page error.    if think server error, please contact webmaster.  error 404 localhost apache/2.4.3 (win32) openssl/1.0.1c php/5.4.7 

this code

<?php session_start(); if(isset($_session["authenticated"])) { if($_session["authenticated"]==true) ?> <!doctype html> <html> <head><title>home</title></head> <body> <a href="logout.php">logout</a> <?php if(isset($_get["engine"])) { if($_get["engine"]=="google") header("location:http://www.google.com/search?q=".$_get["q"]); elseif($_get["engine"]=="yahoo") header("location:http://search.yahoo.com/search?q=".$_get["q"]); if($_get["engine"]=="bing") header("location:http://www.bing.com/search?q=".$_get["q"]); } ?> <form action="fakesearch.php" method="get"> <input type="text" name="q" value=""/><br/> google <input type="radio" name="engine" value="google"/><br/> yahoo <input type="radio" name="engine" value="yahoo"/><br/> bing <input type="radio" name="engine" value="bing"/><br/> <input type="submit"/> </form> </body> </html> <?php } else{ header("location:login.php."); }?> 

in form action using fakesearch.php

<form action="fakesearch.php" method="get"> 

but writing action coding in same file

if(isset($_get["engine"])) { if($_get["engine"]=="google") header("location:http://www.google.com/search?q=".$_get["q"]); elseif($_get["engine"]=="yahoo") header("location:http://search.yahoo.com/search?q=".$_get["q"]); if($_get["engine"]=="bing") header("location:http://www.bing.com/search?q=".$_get["q"]); } 

after clicking submit button, search find fakesearch.php file

try use "#" or make empty in action attribute in form tag.

<?php session_start(); if(isset($_session["authenticated"])) { if($_session["authenticated"]==true) ?> 

try put code after body tag

  if($_session["authenticated"]==true)  { 

i think, open curly brace missing.(idea @ orangepil)

all best!


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -