php Code:<?php
if (!defined('MODULE_FILE')) die('You can\'t access this file directly...');
$index = 0;
if (!defined('INDEX_FILE')) define('INDEX_FILE', true); # Set to FALSE to hide right blocks
if (defined('INDEX_FILE') AND INDEX_FILE === true) {
# auto set right blocks for pre patch 3.1 compatibility
$index = 1;
}
$module_name = basename(dirname(__FILE__));
if (!is_user($user)) {
header('Location: /');
exit;
}
date_default_timezone_set("America/Chicago");
if (!isset($op)) $op = '';
if (!isset($forumname)) $forumname = '';
if (!isset($firstname)) $firstname = '';
if (!isset($lastname)) $lastname = '';
if (!isset($gamename)) $gamename = '';
if (!isset($address)) $address = '';
if (!isset($city)) $city = '';
if (!isset($state)) $state = '';
if (!isset($zipcode)) $zipcode = '';
if (!isset($country)) $country = '';
if (!isset($phone)) $phone = '';
if (!isset($email)) $email = '';
if (!isset($comments)) $comments = '';
switch ($op) {
default:
form_index();
break;
case 'sent':
csrf_check();
form_sent($forumname, $firstname, $lastname, $gamename, $address, $city, $state, $zipcode, $country, $phone, $email, $comments);
break;
}
die();
function form_index() {
global $db, $prefix, $module_name, $user, $userinfo, $cookie;
if (is_user($user)) {
$userinfo = getusrinfo($user);
$forumname = $userinfo['username'];
} else {
$userinfo = false;
$forumname = '';
}
include_once 'header.php';
OpenTable();
echo '<div style="width: 800px; margin: 0 auto; text-align: center">' , PHP_EOL
,' <h1>Membership Information Form</h1><br />' , PHP_EOL
,' <h2>Please provide as much information as you feel comfortable sharing.<br />'
,'This information will not be shared with anyone and will only be viewable by Council Members</h2>' , PHP_EOL
,'</div>' , PHP_EOL
,'<br />' , PHP_EOL
,'<form method ="post" name="form" action = "modules.php?name=' , $module_name , '">' , PHP_EOL
,'<input type="hidden" name="op" value="sent" />' , PHP_EOL
,' <table align="center" width="400" border="2" cellspacing="3" cellpadding="2" style="border-style:solid">' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Forum User Name </td>' , PHP_EOL
,' <td><input name="forumname" type = "text" id="forumname" value="' , $forumname , '" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> First Name</td>' , PHP_EOL
,' <td><input name="firstname" type="text" id="firstname" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Last Name</td>' , PHP_EOL
,' <td><input name = "lastname" type = "text" id="lastname" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Gaming Name</td>' , PHP_EOL
,' <td><input name="gamename" type="text" id="gamename" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Street Address</td>' , PHP_EOL
,' <td><input name = "address" type = "text" id="address" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> City</td>' , PHP_EOL
,' <td><input name = "city" type = "text" id="city" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px; width:93px"> State/Province</td>' , PHP_EOL
,' <td><input name = "state" type="text" id="state" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Zipcode</td>' , PHP_EOL
,' <td><input name="zipcode" type="text" id="zipcode" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Country</td>' , PHP_EOL
,' <td><input name="country" type="text" id="country" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Phone</td>' , PHP_EOL
,' <td><input name="phone" type="text" id="phone" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:93px"> Working Email</td>' , PHP_EOL
,' <td><input name = "email" type = "text" id="email" value="" style="width:279px" /></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,'</table>' , PHP_EOL
,'<br />' , PHP_EOL
,'<div class="text-center">' , PHP_EOL
,' <table align="center" width="400" border="2" cellspacing="3" cellpadding="2" style="border-style:solid">' , PHP_EOL
,' <tr>' , PHP_EOL
,' <td style="font-weight:bold; width:193px"> We Welcome<br /> Your Comments</td>' , PHP_EOL
,' <td><textarea name="comments" id="comments" cols="43" rows="15"></textarea></td>' , PHP_EOL
,' </tr>' , PHP_EOL
,'</table>' , PHP_EOL
,'</div>' , PHP_EOL
,'<div class="text-center" style="margin-top: 50px; font-weight: bold;">' , PHP_EOL
,' <input style="cursor: pointer" name="add" type="submit" value="Submit" />' , PHP_EOL
,'</div>' , PHP_EOL
,'</form>' , PHP_EOL;
CloseTable();
include_once 'footer.php';
}
function form_sent($forumname, $firstname, $lastname, $gamename, $address, $city, $state, $zipcode, $country, $phone, $email, $comments) {
global $db, $prefix;
if ($forumname == '') {
include_once 'header.php';
OpenTable();
echo '<div class="text-center">Error! - No username submitted!<br /><br />' , _GOBACK , '</div>' , PHP_EOL;
CloseTable();
include_once 'footer.php';
exit;
}
$forumname = $db->sql_escape_string(htmlspecialchars_decode(check_html($forumname, 'nohtml'), ENT_QUOTES));
$firstname = $db->sql_escape_string(htmlspecialchars_decode(check_html($firstname, 'nohtml'), ENT_QUOTES));
$lastname = $db->sql_escape_string(htmlspecialchars_decode(check_html($lastname, 'nohtml'), ENT_QUOTES));
$gamename = $db->sql_escape_string(htmlspecialchars_decode(check_html($gamename, 'nohtml'), ENT_QUOTES));
$address = $db->sql_escape_string(htmlspecialchars_decode(check_html($address, 'nohtml'), ENT_QUOTES));
$city = $db->sql_escape_string(htmlspecialchars_decode(check_html($city, 'nohtml'), ENT_QUOTES));
$state = $db->sql_escape_string(htmlspecialchars_decode(check_html($state, 'nohtml'), ENT_QUOTES));
$zipcode = $db->sql_escape_string(htmlspecialchars_decode(check_html($zipcode, 'nohtml'), ENT_QUOTES));
$country = $db->sql_escape_string(htmlspecialchars_decode(check_html($country, 'nohtml'), ENT_QUOTES));
$phone = $db->sql_escape_string(htmlspecialchars_decode(check_html($phone, 'nohtml'), ENT_QUOTES));
$email = $db->sql_escape_string(htmlspecialchars_decode(check_html($email, 'nohtml'), ENT_QUOTES));
$comments = str_replace("\r\n", '<br />', $comments);
$comments = $db->sql_escape_string(check_html($comments, ''));
$result = $db->sql_query('INSERT INTO `members` VALUES '."(NULL, '$forumname', '$firstname', '$lastname', '$gamename', '$address', '$city', '$state', '$zipcode', '$country', '$phone', '$email', '$comments')");
include_once 'header.php';
OpenTable();
if ($result) {
echo '<div class="text-center">Thank you!<br /><br />' , _GOBACK , '</div>' , PHP_EOL;
} else {
echo '<div class="text-center">Failed!<br /><br />' , _GOBACK , '</div>' , PHP_EOL;
}
CloseTable();
include_once 'footer.php';
}
|