00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

PHP: Google script

1,224 Views | 11 Replies
New Topic Respond to this Topic

PHP: Google script 2007-04-19 09:19:41


Ever wanted google on your site? well this is how

Open the document you want to display the google script find where you want it to display and enter

<?
print("<form method=get action=http://www.google.com/search? target=blank>\n");
print("<table border=0 cellspacing=0 cellpadding=5 align=center>\n");
print("<tr><td class=colhead align=center>Google</td></tr>\n");
print("<tr><td class=main align=center><img title=Google src=http://google.com/images/logo.gif></td></
tr>\n");
print("<tr><td class=main align=center>\n");
print("Search: <input type=text name=q value='' maxlength=300 size=70></td></tr>\n");
print("</td></tr>\n");
print("<tr><td class=main align=center>\n");
print("<input type=submit name=btng value=Search> <input type=reset value=Reset>\n");
print("</td></tr>\n");
print("</table>\n");
print("</form>\n");
?>

Response to PHP: Google script 2007-04-19 09:49:47


At 4/19/07 09:19 AM, Kevski wrote: <?
print("<form method=get action=http://www.google.com/search? target=blank>\n");
print("<table border=0 cellspacing=0 cellpadding=5 align=center>\n");
print("<tr><td class=colhead align=center>Google</td></tr>\n");
print("<tr><td class=main align=center><img title=Google src=http://google.com/images/logo.gif></td></
tr>\n");
print("<tr><td class=main align=center>\n");
print("Search: <input type=text name=q value='' maxlength=300 size=70></td></tr>\n");
print("</td></tr>\n");
print("<tr><td class=main align=center>\n");
print("<input type=submit name=btng value=Search> <input type=reset value=Reset>\n");
print("</td></tr>\n");
print("</table>\n");
print("</form>\n");
?>

Your script is highly inefficient. Firstly, you are assuming that people will want to use a table to present the form field - in actual fact this presentation does not need to be part of the script, as it can be handled externally via CSS.

Secondly running all that HTML through the print() function is going to put more load on the server than if you just wrote out the HTML in the document. It also would save bytecode as you wouldn't be doing print() over and over.

Thirdly using print() every time for a new line is extremely bad practice, especially as PHP can very easily cope with whitespace.

print( "
<p>Hello</p>\n
<p>Testing paragraph<p>\n

<p>Third test</p>\n
");

Is the same as:

print("<p>Hello</p>\n<p>Testing paragraph<p>\n<p>Third test</p>\n");

And also it doesn't appear that you're using PHP there at all, just printing out a HTML form - which is not what PHP should be used for.

Finally you haven't even documented your 'tutorial' - people will not learn if you just give them a script to copy and paste. You need to explain how it works. This tutorial fails.


> twitter.

Response to PHP: Google script 2007-04-19 10:29:17


Wow! I'm impressed? I'm guessing that you spent quite a lot of time writing this, so the community thanks you for this wonderful addition to the PHP tutorials!


BBS Signature

Response to PHP: Google script 2007-04-19 10:35:05


You can get the code for the search box on google. There's a page that gives you it. I've had a google search box on my site before.

Response to PHP: Google script 2007-04-19 10:47:28


At 4/19/07 10:35 AM, Andy-Smithy wrote: You can get the code for the search box on google. There's a page that gives you it. I've had a google search box on my site before.

I have too but it wasn't as "complicated" and large as this script. It was actually pointless to have it on my site (as it is for many sites) so I took it off. You're better off writing your own search script to search your own site if you're going to put on one there.

Response to PHP: Google script 2007-04-19 12:07:47


What is next, hello world in php?


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.

Response to PHP: Google script 2007-04-19 13:50:43


Fails miserably.


BBS Signature

Response to PHP: Google script 2007-04-19 13:50:52


I demand a tutorial on how to open a PHP tag!

Well, it would be as useful as this.


"My software never has bugs. It just develops random features. " - Unknown

[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]

BBS Signature

Response to PHP: Google script 2007-04-19 13:53:38


At 4/19/07 01:50 PM, elbekko wrote: I demand a tutorial on how to open a PHP tag!

Well, it would be as useful as this.

That one might actually have a correct tag in it...

Response to PHP: Google script 2007-04-19 13:56:24


At 4/19/07 01:50 PM, elbekko wrote: I demand a tutorial on how to open a PHP tag!

How do you open a PHP tag? Oh and does it have to be closed or can I just leave it hanging? If it has to be closed, then how do I close it? :/

Response to PHP: Google script 2007-04-19 14:43:07


Sorry dude, this isn't even really PHP.

This isn't going to cut it either, but I encourage you to build up your PHP skills and try again in the future.

Response to PHP: Google script 2007-04-19 15:50:47


At 4/19/07 02:37 PM, Potempkin wrote: OR you could just go to Google > Right Click > View Source or something like that, and thats the search page thing.

What are you talking about? It doesn't work like that. Google, like many search engines, were written in a server-side language, which means that you can't see that language, you can only see HTML, Javascript, CSS because it's client-side.