Solved

PHP coding for Google Search

Posted on 2011-09-05
7
236 Views
Last Modified: 2012-05-12
Hi,

I would like to add a google custom search for the site http://secureinfo.info/
I want the search bar to appear in the right corner of the header section.

Attached is the current header.php file. If you need any other php file, please let me know.

Any help is appreciated as i do not know much about any php coding. I have the google code for the search bar and the search result page.

Thanks
header.php
0
Comment
Question by:ujitnos
  • 4
  • 3
7 Comments
 
LVL 8

Accepted Solution

by:
ropenner earned 500 total points
Comment Utility
line 31 and 32 are...

<body <?php body_class(); ?>>

<?php


insert your code for the google search inbetween these two.  If it is PHP code then it is enclosed in <php ?> tags otherwise if it is HTML only then plop it in there.

To position it to the far top right you can use a table to contain it and absolute HTML positioning.  A sample of how it may appear in the header.php file is below... starting at line 31

<body <?php body_class(); ?>>
      <TABLE style="position:absolute; top:0px;right:5px">your stuff</TABLE>
<?php

code below is a working example placed right after the body tag

<html>

<body>

   <TABLE style="position:absolute; top:0px;right:5px">

   	<TR>

   		<TD> 

   			<SCRIPT language=javascript>

   				function addSite() {

   					var query = document.getElementById('q').value;

   					document.location.href="http://google.com/search?q="+query+"+site%3Asecurityinfo.info&hl=en&biw=1208&bih=685&num=10&lr=&ft=i&cr=&safe=images&tbs=";

   					return false;

   				}

				</SCRIPT>

   			<FORM onsubmit="javacript:return addSite();">

		   		<INPUT type=text size=20 id=q name=q>

		   	</FORM>

   		</TD>

   	</TR>

   </TABLE>

</BODY>

</HTML>

Open in new window

0
 
LVL 10

Author Comment

by:ujitnos
Comment Utility
Ok, please review the page. I need to move it a bit down, in line with the title "Secure Info" How to?

I still not able to produce search results, but i will look into that.

This is what i inserted:-

<TABLE style="position:absolute; right:150px">
<form action="http://secureinfo.info/search-results" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="partner-pub-80feferf823723193:gtfedsgzg3104" />
    <input type="hidden" name="cof" value="FORID:10" />
    <input type="hidden" name="ie" value="UTF-8" />
    <input type="text" name="q" size="55" />
    <input type="submit" name="sa" value="Search" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>
</TABLE>
0
 
LVL 10

Author Comment

by:ujitnos
Comment Utility
Hi, I also noticed that it is not aligned properly in Firefox
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 8

Expert Comment

by:ropenner
Comment Utility
The form needs to be within a table row and data cell

you need to put
<TABLE>
<TR><TD>

  ... your stuff

</TD></TR>
</TABLE>
  otherwise it pushes the content outside of the table ... then you can play with the alignment

0
 
LVL 10

Author Comment

by:ujitnos
Comment Utility
Ok, thanks, got that right. Now how do i move it a bit down ?
0
 
LVL 8

Assisted Solution

by:ropenner
ropenner earned 500 total points
Comment Utility
add to your table's style how far from the TOP of the screen you want it to appear.  It is in the original post's code as well


eg.
style="position:absolute; top:20px; right:50px"
0
 
LVL 10

Author Closing Comment

by:ujitnos
Comment Utility
Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now