Reputation: 1
This code works perfectly but if I my form in different page it does not work
$name = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ""; // Andrew
$phoneBook = array("Andrew" => 2753, "Colin" => 2863, "Ken" => 2782);
foreach($phoneBook as $k => $v)
{
if( $k == $name ){
echo $k. " ".$v; // Andrew 2753
}
}
?>
<form action = "kds.php" method ="GET">
name : <input type = "text" name = "name"/>
<input type = "submit"/>
</form>
Upvotes: 0
Views: 24
Reputation: 2896
You have the action relative to the current page. So if you are in www.mysite.com
the action is www.mysite.com/kds.php
, but if you are in www.mysite.com/page
the action will be www.mysite.com/page/kds.php
. Yoy can set the action relative to the root setting like this <form action = "/kds.php" method ="GET">
Upvotes: 1