html - Search box when you type in the name, contact info will appear using PHP -
search box when type in name, contact info appear using php. i'm using "include" partial in website. page put code "index.php?section=contact" become site 'contact' page.
<?php if (isset ($_get["name"])) { $phone = $_get["name"]; } else { $phone = ""; } $name = array ("naszrul 012-3456789"=>"naszrul","badarudin 012-3456788"=>"badarudin") ?> <div id="content"> <form method="get" action="_contact.php"> name: <input type="text" name="name"> <input type="submit"> </form> <br> <?php echo array_search ("$phone",$name); ?> </div>
in _contact.php
(which contact page partial) file, put code. instead of showing both _contact.php + index.php
partial, show _contact.php
page , url become _contact.php?name=naszrul
how include "index.php
, _contact.php
, , $phone
in one?
index.php
below
<?php if( isset($_get["section"]) ) { $section = $_get["section"]; } else { $section = ""; } ?> <!doctype html> <html> <head> <title>nasx</title> <link rel="stylesheet" type="text/css" href="layout.css"> </head> <body> <div id="container"> <div id="header" align="center"> <a href="index.html"><img src="header.png"></a> </div> <div id="navbar"> <div class="button"><a href="index.php?section=home" class="link">home</a></div> <div class="button"><a href="index.php?section=about" class="link">about</a></div> <div class="button"><a href="index.php?section=works" class="link">works</a></div> <div class="button"><a href="index.php?section=contact" class="link">contact</a></div> </div> <?php if($section == "home" || $section == "") { include "_home.php"; } elseif ($section == "about") { include "_about.php"; } elseif ($section == "works") { include "_works.php"; } elseif ($section == "contact") { include "_contact.php"; } ?> </div> </body> </html>
Comments
Post a Comment