Registration UH Username

Send Snippet To: Save this snippet to Code Collector Pro -- view all bassglider's snippets
language: PHP
license: Other

Code for Snippet:

if (!isset($_POST['submit'])) {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<title>UH Username Request Form</title>
<div class=\"title\">
University of Hawai'i Information Technology Services <BR>
Department UH Username Request Form<BR><BR>
<form action=\"/registration.php\" method = \"POST\">
<LABEL for=\"Name\">Name: </LABEL>
	<INPUT type=\"text\" id=\"Name\"><BR>
<LABEL for=\"Date\">Date: </LABEL>
	<INPUT type=\"text\" id=\"Date\"><BR>
<LABEL for=\"UH Number\">UH Number: </LABEL>
	<INPUT type=\"text\" id=\"UH Number\"><BR>
<LABEL for=\"Name Of Department\">Name Of Department: </LABEL>
	<INPUT type=\"text\" id=\"Name Of Department\"><BR>
<LABEL for=\"Campus Address\">Campus Address: </LABEL>
	<INPUT type=\"text\" id=\"Campus Address\"><BR>
<LABEL for=\"Campus Phone\">Campus Phone: </LABEL>
	<INPUT type=\"text\" id=\"Campus Phone\"><BR>
<LABEL for=\"Fax\">Fax: </LABEL>
	<INPUT type=\"text\" id=\"Fax\"><BR>
Please Check One:<br>
<input type=\"checkbox\" name=\"Field1\" value=\"New\">New<br>
<input type=\"checkbox\" name=\"Field1\" value=\"Renewal\">Renewal<br>
<input type=\"checkbox\" name=\"Field1\" value=\"Change Owner\">Change Owner<br>
<input type=\"checkbox\" name=\"Field1\" value=\"Update\">Update<br>
<input type=\"checkbox\" name=\"Field1\" value=\"Instructional Course\">Instructional Course<br>
<input type=\"submit\" value=\"Submit\" name=\"submit\">
// Stick POST data into variables:
if (isset($_POST['Name'])) {
	$Name = $_POST['Name'];
	}else { echo "You forgot to enter your name!"; exit(); }
if (isset($_POST['Date'])) {
	$Date = $_POST['Date'];
	} else { echo "You forgot to enter your Date!"; exit(); }
if (isset($_POST['UH Number'])) {
	$UH = $_POST['UH Number'];
	} else { echo "You forgot to enter your UH Number!"; exit(); } 
if (isset($_POST['Name Of Department'])) {
	$DeptName = $_POST['Name Of Department'];
	} else { echo "You forgot to enter the name of your department!"; exit(); } 
if (isset($_POST['Campus Address'])) {
	$CampAddr = $_POST['Campus Address'];
	} else { echo  "You forgot to enter your Campus Address!"; exit(); } 
if (isset($_POST['Campus Phone'])) {
	$CampPhne = $_POST['Campus Phone'];
	} else { echo "You forgot to enter your Campus Phone Number!"; exit(); } 
if (isset($_POST['Fax'])) {
	$Fax = $_POST['Fax'];
	} else { echo "You forgot to enter your Fax Number!"; exit(); } 
if (isset($_POST['Field1'])) {
	$Field1 = $_POST['Field1'];
	} else { echo "You must check one box!"; exit(); } 
// Check to see whats in the Database.
// 'UH Number' is the primary key at the moment
// Connect to database
mysql_connect("localhost", "root", "password");
// Formulate Query To Grab Existing stuff
$query = sprintf("SELECT Name, Date, UH, DeptName, CampAddr, CampPhne, Fax, Field1 FROM pdetails WHERE UH='%s'", 
// Perform Query 
$result = mysql_query($query);
// Check result for error (in case of bad query due to malformed POST data)
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
// check if data exists
while ($row = mysql_fetch_assoc($result)) {
	$dbName = $row['Name'];
	$dbDate = $row['Date'];
	$dbUH = $row['UH'];
	$dbDeptName = $row['DeptName'];
	$dbCampAddr = $row['CampAddr'];
	$dbCampPhne = $row['CampPhne'];
	$dbFax = $row['Fax'];
	$dbField1 = $row['Field1'];
if (isset($dbName)) { 
if ($status="exists") {
	echo " The UH number you entered ($dbUH) already exists!"; exit();
// Now stuff new data into database
$query = "INSERT INTO pdetails (Name, Date, UH, DeptName, CampAddr, CampPhne, Fax, Field1) VALUES ('$Name', '$Date', '$UH', '$DeptName', '$CampAddr', '$CampPhne', '$Fax', '$Field1')";
echo "Data Added!";
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 3455
Date Added: 2008-03-20 01:38:41
Last Modified: 0000-00-00 00:00:00

Web Analytics