[Typo3] How to send form data to Page PHP Content

Mark Gillingham markgill at uwalumni.com
Wed Apr 13 04:05:20 CEST 2005


It's taken me months, but I've finally figured this out. I got a 
very simple form that collects just one input and uses that to 
delimit a query. I had to read documents that I didn't think were 
important. The most important of which was the Project Coding 
Guidelines. I don't think of myself as a developer and didn't 
think I needed this information, but I was wrong. I credit the 
Wiki with making me aware. Especially read the section on <a 
href="http://typo3.org/documentation/document-library/doc_core_cgl/Variables_and_Consta/#oodoc_part_260">Variables 
and Constants</a>. Had I read this ages ago, it would have saved 
much time.

Enjoy T3!

Some of the PHP Page Content script follows:

// The following is most important, it uses a T3 system function 
to get the page URI
$this = t3lib_div::getIndpEnv(REQUEST_URI);
// Determine what system vars I have access to
$state = t3lib_div::_GP('state') ;

$query = 'SELECT * FROM salesrep WHERE statecode=';
//$query .= '"IL"';
$query .= '"'.$state.'"';

$connection = mysql_connect("localhost", "username", "password");
mysql_select_db("db_name", $connection);

$result = mysql_query($query, $connection);

echo '<table>';
echo 
'<tr><th>State</th><th>Name</th><th>Phone</th><th>E-mail</th></tr>' ;
while ($row = mysql_fetch_assoc($result))
   echo 
'<tr><td>'.$row["state"].'</td><td>'.$row["name"].'</td><td> '. 
$row["phone"].'</td><td> '. $row["email"].'</td></tr>';

echo '</table>';

//The form is just this
echo <<<END
   <form action=$this method=post>
   <dd class="selection">Enter the two-letter abbreviation for 
your state and press return:
   <input type=text size=2 maxlength=3 name="state"></dd>
   <input type="submit" name="submit_button" >
   </form>
END;



More information about the TYPO3-english mailing list