<!DOCTYPE html> <head> <title> Form and script all in one... </title> <link rel="stylesheet" href="css/base.css" /> </head> <body> <h3>Dumping $_GET array </h3> <?php echo "<pre>"; print_r($_GET); echo "</pre>"; ?> <hr> <?php if (isset($_GET['OK'])) { handleform(); } else { echo "Fill this form in and submit it !!"; } displayForm(); // I always want to display the form ?> </body> </html> <?php function handleform() { echo "<pre>" . print_r($_GET) . "</pre>"; $name = isset($_GET['username']) ? $_GET['username'] : ""; $gradyear = isset($_GET['gradyear']) ? $_GET['gradyear'] : ""; $knowsjava = isset($_GET['knowsJava']) ? "yes" : "";
function displayContinentInfo($continent) { echo "<fieldset class=output>"; echo "<legend>" . $continent . "</legend>"; handleform($continent); echo "</fieldset>"; }
<?php //IF FILL OUT FORM, GRAB INFORMATION if (isset($_POST['formsubmitted'])) { $name = $_POST['name']; $email = $_POST['email']; $pw1 = $_POST['pw1']; $pw2 = $_POST['pw2']; $membership = $_POST['membership']; //echo "name is $name email is $email pw1 is $pw1 and pw2 is $pw2 membership is $membership <br/>"; connectToDB(); checkPasswords($pw1, $pw2); checkEmail($email); //handleform($name, $email, $pw1, $membership); //new stuff if (!strcmp($pw1, $pw2) && checkEmail($email) == 0) { handleform($name, $email, $pw1, $membership); echo "<br/>Thank you for your interest!"; } } ?> <?php function checkPasswords($pw1, $pw2) { if (!strcmp($pw1, $pw2)) { return $pw1; } else { echo "Passwords do not match please "; } ?> <a href="http://cslab.bc.edu/~baconju/club">Try Again</a><?php
<html lang="en"> <head> <meta charset="UTF-8" /> <title>MySQL and PHP </title> <style type = "text/css"> body {font-family: Verdana, sans-serif;} </style> </head> <body> <pre><?php print_r($_GET); ?> </pre> <?php if (isset($_GET['formsubmitted'])) { handleform("studentmenu"); } displayform("studentmenu"); ?> </body> </html> <?php function handleform($id) { $dbc = connect_to_db("jed"); $query = "select lastname, firstname, major from student where ID='{$id}'"; $result = perform_query($dbc, $query); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); print_r($row); $firstname = $row['firstname'];
<legend>My Report</legend> <?php echo findgasses($xml); echo "<br/>"; echo findkelvin($xml); echo "<br/>"; echo highestbp($xml); echo "<br/>"; ?> </fieldset> <?php if (isset($_GET['formsubmitted'])) { // I only handle the form if the user submitted it $chosenatom = $_GET['atommenu']; handleform($xml, $atomicnumber, $atomicweight); } else { $chosenatom = ""; } displayform($xml); ?> </body> </html> <?php function findgasses($xml) { $GAS = $xml->xpath('ATOM[@STATE="GAS"]'); $str = "";
<?php //If submits form, grab information if (isset($_GET['submit'])) { $name = $_GET['name']; $category = $_GET['category']; $address = $_GET['address']; $phone = $_GET['phone']; $url = $_GET['url']; $user = $_GET['user']; $stars = $_GET['stars']; $price = $_GET['price']; $comment = $_GET['comment']; $loc = makeLocArray(); $lat = $loc['latitude']; $long = $loc['longitude']; handleform($name, $category, $address, $lat, $long, $phone, $url, $stars, $price, $user, $comment); } function getLat() { $address = $_GET['address']; $adr = urlencode($address); $file = file_get_contents("http://geocoder.us/demo.cgi?address=" . $adr); $patterns = "!mapCenterLat = ([0-9]+\\.[0-9]*)!"; preg_match_all($patterns, $file, $res); return htmlentities($res[1][0]); } function getLong() { $address = $_GET['address']; $adr = urlencode($address); $file = file_get_contents("http://geocoder.us/demo.cgi?address=" . $adr);