PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Dec 10, 2018 12:29 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Dec 19, 2017 1:20 pm 
Offline
Forum Contributor

Joined: Wed Jan 18, 2017 4:43 pm
Posts: 197
Folks,

I'm creating like a meta engine where you choose which searchengine to use. I'll get to the point where my site will show you search results that have links from all searchengine results. But as for now, let's take things one step at a time.

OFF TOPIC:

Oh man! Shut the F* Up! (I got a lousy fox howling at the back of my backyard near the woods!).

It shut the hell up once I wrote this. maybe, I'm becoming psychic some-how getting my message across to creepy things! Lol!

TOPIC:

For now, I'm giving user the option to choose which searchengine to use. Right now, I've managed to program where the search results (from your chosen searchengine) is shown on the current window. I want it to show in a new window. So, how to code that part ? I've googled and checked Stack Over Flow and I see a lot of others are searching for the same code but no one is having any luck!

Here's my code for now:

Syntax: [ Download ] [ Hide ]
<?php

/*
ERROR HANDLING
*/

declare&#40;strict_types=1&#41;;
ini_set&#40;&#39;display_errors&#39;, &#39;1&#39;&#41;;
ini_set&#40;&#39;display_startup_errors&#39;, &#39;1&#39;&#41;;
error_reporting&#40;E_ALL&#41;;
mysqli_report&#40;MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT&#41;;

//Step 2: Check user submitted details.      
    //2A. Check whether user made all the required inputs or not.
    if &#40;isset&#40;$_POST["keywords"]&#41; && isset&#40;$_POST["searchengine"]&#41;&#41; 
    {       
        //2B. Create variables based on user inputs.
        $keywords = trim&#40;$_POST[&#39;keywords&#39;]&#41;;
        $searchengine = trim&#40;$_POST[&#39;searchengine&#39;]&#41;;
        
        if &#40;strlen&#40;$searchengine&#41; < 1&#41;
        {
            $searchengine = &#39;mysearchengine&#39;;
        }
        elseif &#40;$searchengine = &#39;google&#39;&#41;
        {
            $serp = "https://www.google.com/search?q=$keywords";
            header&#40;"location: $serp"&#41;;
        }
        elseif &#40;$searchengine = &#39;yahoo&#39;&#41;
        {
            $serp = "https://search.yahoo.com/search?p=$keywords";
            header&#40;"location: $serp"&#41;;
        }
        elseif &#40;$searchengine = &#39;msn&#39;&#41;
        {
            $serp = "https://www.bing.com/search?q=$keywords";
            header&#40;"location: $serp"&#41;;
        }
        echo "$searchengine";
        echo "$keywords";
    }
}
?>
            
<!DOCTYPE html>
<html>
<head>
<title><?php $site_name ?>Meta Searcher</title>
    <meta charset="utf-8">
</head>
<body>
<form method="post" action="">
    <p align="left"><h2>Meta Searcher</h2></p>
    <fieldset>
        <label for="keywords_search">Search Keywords:</label>
        <input type="text" name="keywords" id="kw" value="" placeholder="Keywords"><br>
        <label for="searchengine">Searchengine:</label>
        <input type="radio" name="searchengine" value="mysearchengine" <?php if&#40;isset&#40;$_POST[&#39;mysearchengine&#39;]&#41;&#41; { echo &#39;checked&#39;; }?> required>My Searchengine
        <input type="radio" name="searchengine" value="google" <?php if&#40;isset&#40;$_POST[&#39;google&#39;]&#41;&#41; { echo &#39;checked&#39;; }?> required>Google
        <input type="radio" name="searchengine" value="yahoo" <?php if&#40;isset&#40;$_POST[&#39;yahoo&#39;]&#41;&#41; { echo &#39;checked&#39;; }?> required>Yahoo
        <input type="radio" name="searchengine" value="msn" <?php if&#40;isset&#40;$_POST[&#39;msn&#39;]&#41;&#41; { echo &#39;checked&#39;; }?> required>Msn
    </fieldset>
    <div class="SubmitsAndHiddens">
        <input type="hidden" name="meta_searcher" id="meta_searcher" />
        <br>
        <button type="submit">Search!</button>
        <br>
    </div>
</form>
</body>
</html>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group