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.