Beispiel #1
0
function showForm()
{
    # shows form so user can enter their name.  Initial scenario
    get_header();
    #defaults to header_inc.php
    echo '<script type="text/javascript" src="' . VIRTUAL_PATH . 'include/util.js"></script>
	<script type="text/javascript">
		function checkForm(thisForm)
		{//check form data for valid info
			//if(empty(thisForm.YourName,"Please Enter Your Name")){return false;}
			return true;//if all is passed, submit!
		}
	</script>
	<h3 align="center">' . smartTitle() . '</h3>
	<p align="center">Please enter your name</p> 
	<form action="' . THIS_PAGE . '" method="post" onsubmit="return checkForm(this);">
		<table align="center">
			<tr>
				<td align="right">
					Name
				</td>
				<td>
					<input type="text" name="Name" required="required" /><font color="red"><b>*</b></font> <em>(alphabetic only)</em>
				</td>
			</tr>
            
            <tr>
				<td align="right">
					Hobby
				</td>
				<td>
					<input type="text" name="Hobby" required="required" /><font color="red"><b>*</b></font> <em>(alphabetic only)</em>
				</td>
			</tr>
            
            <tr>
				<td align="right">
					Allowance
				</td>
				<td>
					<input type="text" name="Allowance" required="required" /><font color="red"><b>*</b></font> <em>(numeric only)</em>
				</td>
			</tr>
                    
			<tr>
				<td align="center" colspan="2">
					<input type="submit" value="Please Enter Your Name"><em>(<font color="red"><b>*</b> required field</font>)</em>
				</td>
			</tr>
		</table>
		<input type="hidden" name="act" value="display" />
	</form>
	';
    get_footer();
    #defaults to footer_inc.php
}
$config->metaDescription = ''; #Fills <meta> tags.
$config->metaKeywords = '';
$config->metaRobots = '';
$config->loadhead = ''; #load page specific JS
$config->banner = ''; #goes inside header
$config->copyright = ''; #goes inside footer
$config->sidebar1 = ''; #goes inside left side of page
$config->sidebar2 = ''; #goes inside right side of page
$config->nav1["page.php"] = "New Page!"; #add a new page to end of nav1 (viewable this page only)!!
$config->nav1 = array("page.php"=>"New Page!") + $config->nav1; #add a new page to beginning of nav1 (viewable this page only)!!
*/
$mySurvey = new Survey(1);
if ($mySurvey->isValid) {
    $config->titleTag = "'" . $mySurvey->Title . "' Survey!";
} else {
    $config->titleTag = smartTitle();
    //use constant
}
#END CONFIG AREA ----------------------------------------------------------
get_header();
#defaults to theme header or header_inc.php
?>
<h3><?php 
echo THIS_PAGE;
?>
</h3>

<p>This is a proof of concept for the initial SurveySez objects.</p>
<p>It features the Survey, Question & Answer Objects</p>
<p>This page is currently hard wired to the first Survey only.</p>
<p>It is a model intended to be changed to survey_view.php, with the ID of a survey to be passed in via the QueryString</p>
Beispiel #3
0
* building DB applications using IDB connections
*
* @package SurveySez
* @author Blake Schwartz <*****@*****.**>
* @version 0.1 2015/05/12
* @link http://blakehschwartz.com/
* @license http://www.apache.org/licenses/LICENSE-2.0
* @see survey_inc.php  
* @todo none
*/
# '../' works for a sub-folder.  use './' for the root
require '../inc_0700/config_inc.php';
#provides configuration, pathing, error handling, db credentials
$config->titleTag = smartTitle();
#Fills <title> tag. If left empty will fallback to $config->titleTag in config_inc.php
$config->metaDescription = smartTitle() . ' - ' . $config->metaDescription;
# SQL statement - PREFIX is optional way to distinguish your app
$sql = "select Title, Description from sp15_surveys";
//END CONFIG AREA ----------------------------------------------------------
get_header();
#defaults to header_inc.php
?>
<h3 align="center"><?php 
echo $config->titleTag;
?>
</h3>
<?php 
#IDB::conn() creates a shareable database connection via a singleton class
$result = mysqli_query(IDB::conn(), $sql) or die(trigger_error(mysqli_error(IDB::conn()), E_USER_ERROR));
echo '<div align="center"><h4>SQL STATEMENT: <font color="red">' . $sql . '</font></h4></div>';
if (mysqli_num_rows($result) > 0) {
function showName()
{
    #form submits here we show entered name
    get_header();
    #defaults to footer_inc.php
    if (!isset($_POST['YourName']) || $_POST['YourName'] == '') {
        //data must be sent
        feedback("No form data submitted");
        #will feedback to submitting page via session variable
        myRedirect(THIS_PAGE);
    }
    if (!ctype_alnum($_POST['YourName'])) {
        //data must be alphanumeric only
        feedback("Only letters and numbers are allowed.  Please re-enter your name.");
        #will feedback to submitting page via session variable
        myRedirect(THIS_PAGE);
    }
    $myName = strip_tags($_POST['YourName']);
    # here's where we can strip out unwanted data
    echo '<h3 align="center">' . smartTitle() . '</h3>';
    echo '<p align="center">Your name is <b>' . $myName . '</b>!</p>';
    echo '<p align="center"><a href="' . THIS_PAGE . '">RESET</a></p>';
    get_footer();
    #defaults to footer_inc.php
}
$config->metaKeywords = 'SCCC,Seattle Central,ITC281,database,mysql,php';
$config->metaRobots = 'no index, no follow';
$config->loadhead = ''; #load page specific JS
$config->banner = ''; #goes inside header
$config->copyright = ''; #goes inside footer
$config->sidebar1 = ''; #goes inside left side of page
$config->sidebar2 = ''; #goes inside right side of page
$config->nav1["page.php"] = "New Page!"; #add a new page to end of nav1 (viewable this page only)!!
$config->nav1 = array("page.php"=>"New Page!") + $config->nav1; #add a new page to beginning of nav1 (viewable this page only)!!
*/
# END CONFIG AREA ----------------------------------------------------------
get_header();
#defaults to theme header or header_inc.php
?>
<h3 align="center"><?php 
echo smartTitle();
?>
</h3>

<p>This page, along with <b>demo_view_pager.php</b>, demonstrate a List/View web application.</p>
<p>It was built on the mysql shared web application page, <b>demo_shared.php</b></p>
<p>This page is the entry point of the application, meaning this page gets a link on your web site.  Since the current subject is muffins, we could name the link something clever like <a href="<?php 
echo VIRTUAL_PATH;
?>
demo_list_pager.php">Muffins</a></p>
<p>Use <b>demo_list_pager.php</b> and <b>demo_view_pager.php</b> as a starting point for building your own List/View web application!</p> 
<?php 
#reference images for pager
$prev = '<img src="' . VIRTUAL_PATH . 'images/arrow_prev.gif" border="0" />';
$next = '<img src="' . VIRTUAL_PATH . 'images/arrow_next.gif" border="0" />';
# Create instance of new 'pager' class
function editDisplay()
{
    # shows details from a single customer, and preloads their first name in a form.
    global $config;
    if (!is_numeric($_POST['CustomerID'])) {
        //data must be alphanumeric only
        feedback("id passed was not a number. (error code #" . createErrorCode(THIS_PAGE, __LINE__) . ")", "error");
        myRedirect(THIS_PAGE);
    }
    $myID = (int) $_POST['CustomerID'];
    //forcibly convert to integer
    $sql = sprintf("select CustomerID,FirstName,LastName,Email from test_Customers WHERE CustomerID=%d", $myID);
    $result = mysqli_query(IDB::conn(), $sql) or die(trigger_error(mysqli_error(IDB::conn()), E_USER_ERROR));
    if (mysqli_num_rows($result) > 0) {
        //show results
        while ($row = mysqli_fetch_array($result)) {
            //dbOut() function is a 'wrapper' designed to strip slashes, etc. of data leaving db
            $Name = dbOut($row['FirstName']) . ' ' . dbOut($row['LastName']);
            $First = dbOut($row['FirstName']);
            $Last = dbOut($row['LastName']);
            $Email = dbOut($row['Email']);
        }
    } else {
        //no records
        //feedback issue to user/developer
        feedback("No such customer. (error code #" . createErrorCode(THIS_PAGE, __LINE__) . ")", "error");
        myRedirect(THIS_PAGE);
    }
    $config->loadhead .= '
	<script type="text/javascript" src="' . VIRTUAL_PATH . 'include/util.js"></script>
	<script type="text/javascript">
		function checkForm(thisForm)
		{//check form data for valid info
			if(empty(thisForm.FirstName,"Please Enter Customer\'s First Name")){return false;}
			if(empty(thisForm.LastName,"Please Enter Customer\'s Last Name")){return false;}
			if(!isEmail(thisForm.Email,"Please Enter a Valid Email")){return false;}
			return true;//if all is passed, submit!
		}
	</script>';
    get_header();
    echo '<h3 align="center">' . smartTitle() . '</h3>
	<h4 align="center">Update Customer\'s Name</h4>
	<p align="center">Customer: <font color="red"><b>' . $Name . '</b>
	 Email: <font color="red"><b>' . $Email . '</b></font> 
	<form action="' . THIS_PAGE . '" method="post" onsubmit="return checkForm(this);">
	<table align="center">
	   <tr><td align="right">First Name</td>
		   	<td>
		   		<input type="text" name="FirstName" value="' . $First . '">
		   		<font color="red"><b>*</b></font> <em>(alphanumerics & punctuation)</em>
		   	</td>
	   </tr>
	   <tr><td align="right">Last Name</td>
		   	<td>
		   		<input type="text" name="LastName" value="' . $Last . '">
		   		<font color="red"><b>*</b></font> <em>(alphanumerics & punctuation)</em>
		   	</td>
	   </tr>
	   <tr><td align="right">Email</td>
		   	<td>
		   		<input type="text" name="Email" value="' . $Email . '">
		   		<font color="red"><b>*</b></font> <em>(valid email only)</em>
		   	</td>
	   </tr>
	   <input type="hidden" name="CustomerID" value="' . $myID . '" />
	   <input type="hidden" name="act" value="update" />
	   <tr>
	   		<td align="center" colspan="2">
	   			<input type="submit" value="Update Info!"><em>(<font color="red"><b>*</b> required field</font>)</em>
	   		</td>
	   </tr>
	</table>    
	</form>
	<div align="center"><a href="' . THIS_PAGE . '">Exit Without Update</a></div>
	';
    @mysqli_free_result($result);
    //free resources
    get_footer();
}
function addForm()
{
    # shows details from a single customer, and preloads their first name in a form.
    global $config;
    $config->loadhead .= '
	<script type="text/javascript" src="' . VIRTUAL_PATH . 'include/util.js"></script>
	<script type="text/javascript">
		function checkForm(thisForm)
		{//check form data for valid info
			if(empty(thisForm.FirstName,"Please Enter Customer\'s First Name")){return false;}
			if(empty(thisForm.LastName,"Please Enter Customer\'s Last Name")){return false;}
			if(!isEmail(thisForm.Email,"Please Enter a Valid Email")){return false;}
			return true;//if all is passed, submit!
		}
	</script>';
    get_header();
    echo '<h3 align="center">' . smartTitle() . '</h3>
	<h4 align="center">Add Customer</h4>
	<form action="' . THIS_PAGE . '" method="post" onsubmit="return checkForm(this);">
	<table align="center">
	   <tr><td align="right">First Name</td>
		   	<td>
		   		<input type="text" name="FirstName" />
		   		<font color="red"><b>*</b></font> <em>(alphanumerics & punctuation)</em>
		   	</td>
	   </tr>
	   <tr><td align="right">Last Name</td>
		   	<td>
		   		<input type="text" name="LastName" />
		   		<font color="red"><b>*</b></font> <em>(alphanumerics & punctuation)</em>
		   	</td>
	   </tr>
	   <tr><td align="right">Email</td>
		   	<td>
		   		<input type="text" name="Email" />
		   		<font color="red"><b>*</b></font> <em>(valid email only)</em>
		   	</td>
	   </tr>
	   <input type="hidden" name="act" value="insert" />
	   <tr>
	   		<td align="center" colspan="2">
	   			<input type="submit" value="Add Customer!"><em>(<font color="red"><b>*</b> required field</font>)</em>
	   		</td>
	   </tr>
	</table>    
	</form>
	<div align="center"><a href="' . THIS_PAGE . '">Exit Without Add</a></div>
	';
    get_footer();
}
$config->metaDescription = 'Web Database ITC281 class website.'; #Fills <meta> tags.
$config->metaKeywords = 'SCCC,Seattle Central,ITC281,database,mysql,php';
$config->metaRobots = 'no index, no follow';
$config->loadhead = ''; #load page specific JS
$config->banner = ''; #goes inside header
$config->copyright = ''; #goes inside footer
$config->sidebar1 = ''; #goes inside left side of page
$config->sidebar2 = ''; #goes inside right side of page
$config->nav1["page.php"] = "New Page!"; #add a new page to end of nav1 (viewable this page only)!!
$config->nav1 = array("page.php"=>"New Page!") + $config->nav1; #add a new page to beginning of nav1 (viewable this page only)!!
*/
# END CONFIG AREA ---------------------------------------------------------- 

get_header(); #defaults to theme header or header_inc.php
?>
<h3 align="center"><?=smartTitle();?></h3>

<p>This page, along with <b>demo_list_pager.php</b>, demonstrate a List/View web application.</p>
<p>It was built on the mysqli shared web application page, <b>demo_shared.php</b></p>
<p>This page is to be used only with <b>demo_list_pager.php</b>, and is <b>NOT</b> the entry point of the application, meaning this page gets <b>NO</b> link on your web site.</p>
<p>Use <b>demo_list_pager.php</b> and <b>demo_view_pager.php</b> as a starting point for building your own List/View web application!</p> 
<?php
if($foundRecord)
{#records exist - show muffin!
?>
	<h3 align="center">A Yummy <?=$MuffinName;?> Muffin!</h3>
	<div align="center"><a href="<?=VIRTUAL_PATH;?>demo/demo_list_pager.php">More Muffins?!?</a></div>
	<table align="center">
		<tr>
			<td><img src="<?=VIRTUAL_PATH;?>upload/m<?=$myID;?>.jpg" /></td>
			<td>We make fresh <?=$MuffinName;?> muffins daily!</td>
 * link to this page clears old session data, and provides feedback on the number of records thus 
 * effected (deleted).
 *
 * @package nmSession
 * @author Bill Newman (via Larry Ullman) <*****@*****.**>
 * @version 1.21 2010/07/26
 * @link http://www.newmanix.com/ 
 * @license http://opensource.org/licenses/osl-3.0.php Open Software License ("OSL") v. 3.0
 * @see session_db_inc.php 
 * @todo none
 */
require '../inc_0700/config_inc.php';
#provides configuration, pathing, error handling, db credentials
//startSession(); #DB requires session started
//$cleaned = session_clean(86400); #86400 seconds is one day - forces clearing of old sessions
$PageTitle = smartTitle();
#Fills <title> tag. If left empty will default to $PageTitle in config_inc.php
$meta_robots = 'no index, no follow';
#never index admin pages
$collection_duration = 24;
#Length of time in hours a session is allowed to be
//END CONFIG AREA ----------------------------------------------------------
$collection_seconds = $collection_duration * 3600;
#multiply hours x 3600 seconds/hour
$access = "developer";
#admin or higher level can view this page
include_once INCLUDE_PATH . 'admin_only_inc.php';
#session protected page - level is defined in $access var
get_header();
#defaults to header_inc.php
?>