
| Example sources from systhread.net |
| From: systhread.net read times: 129 |
Provided by yangyi at 2009-07-04 20:31:55 |
Some small tricks I have done, working with development tools and interesting code I have written. It is not a tutorial site as much just an interesting place to shuffle around. I do have a tiny software collection available (all of which are an order of magnitude larger than anything here). Contents
Some Small PHP TidbitsThis site really only uses a little PHP at the moment and in three ways; to include common files/data, a feedback form, and a search form. Including files is pretty straightforward, but I found two articles on a feedback and search form thatI thought would be nice to put in the examples. Simple Feedback Form in PHPMy form is similar to this one: <?php
if ($_POST) {
$subject = $_POST['subject'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$message =
Grep Search
The search PHP script while clever has one slight drawback, it is using
a non portable <Search> <form action=<?=$PHP_SELF;?gt;method=post<input type=textname=searchstrvalue=<?php echosize=$searchstr; ?>20maxlength=30/> <input type=submitvalue=Search/> </form> <?php $cmdstr =grep -ir $searchstr dir1/* dir2/*.html about/*; $fp = popen( $cmdstr,r); $myresult = array(); echo (<h3>Search Results</h3>\n); while( $buffer = fgetss ( $fp, 4096 )) { list( $fname, $fline ) = split(:, $buffer, 2 ); if ( !defined( $myresult[$fname] )) $myresult[$fname] = $fline; } if ( count( $myresult )) { echo<ul>\n; while ( list( $fname, $fline ) = each( $myresult)) echo<li><a href=\; } else { echo$fname\>$fname</a> : $fline </li>\n<p>Sorry. Search on <b>$searchstr</b> returned no results.</p>\n; } pclose( $fp ); } ?> Note how the feedback uses a reverse logic, if we have not done a post then print the form yet the search just replaces part of the page on the fly. ...... Please access the below link to view the full content. Original link: http://systhread.net/coding/exsr... |