PHP Code:
<?php require_once("includes/connection.php");
include ("includes/functions.php");
//form validation
if(isset($_POST['submit'])){
$errors=array();
$requiredfields=array('market'=>'Please enter the market question','style'=>'Please answer the style question If not sure just put unsure','message'=>'Please answer the message question If not sure just put unsure','branding'=>'Please answer the branding question If not sure put unsure','name'=>'Please enter your name','email'=>'Please enter your email so we can contact you');
foreach($requiredfields as $fieldname => $requiredfieldsmessage){
if(!isset($_POST[$fieldname]) || empty($_POST[$fieldname]) || strlen(trim($_POST[$fieldname])) == 0) {
$errors[] = $requiredfieldsmessage;
}
}
if(count($errors) == 0){
$_POST = array_map('mysqli_prep', $_POST);
//end form validation
$primary_function = mysqli_prep($_POST['primary_function']);
$go_live = mysqli_prep($_POST['go_live']);
$biz_type = mysqli_prep($_POST['biz_type']);
$market = mysqli_prep( $_POST['market']);
$style = mysqli_prep( $_POST['style']);
$message = mysqli_prep($_POST['message']);
$branding = mysqli_prep($_POST['branding']);
$budget = mysqli_prep($_POST['budget']);
$images = mysqli_prep($_POST['images']);
$name = mysqli_prep($_POST['name']);
$email = mysqli_prep($_POST['email']);
$query = "INSERT into briefing_form (
primary_function,go_live,biz_type,market,style,message,branding,budget,images,name,email)Values('{$primary_function}','{$go_live}','{$biz_type}','{$market}','{$style},'{$message}','{$branding}','{$budget}','{$images}','{$name}','{$email}')";
$result = mysqli_query($connection, $query);
header('Location: brief_return.php');
exit;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome to market!</title>
<link href="Xind4.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="iehacks2.css" />
<![endif]-->
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:543px;
height:115px;
z-index:6;
left: 104px;
top: 159px;
}
#Layer2 {
position:absolute;
width:200px;
height:56px;
z-index:1;
left: 139px;
top: 142px;
}
#Layer3 {
position:absolute;
width:200px;
height:42px;
z-index:6;
left: 453px;
top: 483px;
}
#Layer4 {
position:absolute;
width:212px;
height:43px;
z-index:7;
left: 455px;
top: 727px;
}
#Layer5 {
position:absolute;
width:128px;
height:130px;
z-index:5;
left: 28px;
top: 125px;
outline: #FF0000
}
#Layer6 {
position:absolute;
width:79px;
height:96px;
z-index:1;
left: 24px;
top: -1px;
outline: #FF0000;
}
#Layer7 {
position:absolute;
width:200px;
height:43px;
z-index:8;
left: 453px;
top: 983px;
}
#Layer8 {
position:absolute;
width:139px;
height:131px;
z-index:6;
left: 245px;
top: 125px;
}
#Layer9 {
position:absolute;
width:83px;
height:93px;
z-index:1;
left: 22px;
top: 0px;
}
#Layer10 {
position:absolute;
width:138px;
height:115px;
z-index:7;
left: 432px;
top: 130px;
}
#Layer11 {
position:absolute;
width:86px;
height:90px;
z-index:1;
left: 20px;
top: 4px;
}
#Layer12 {
position:absolute;
width:156px;
height:115px;
z-index:8;
left: 401px;
top: 310px;
}
.style1 {color: #666666}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body >
<div id="wrapper">
<div id="topbit">
<div id="header">
<img src="myimages/marketsheader2.jpg" alt="All you need to advertise youe web site on the internet" width="708" height="89" border="0" usemap="#Map" />
<map name="Map" id="Map"><area shape="rect" coords="567,7,684,78" href="http://www.outitgoes.com/" target="_blank" />
</map></div>
<!--end header-->
<div id="mailhead"><a href="http://www.outitgoes.com/"></a><img src="myimages/contact.gif" alt="Log in to your Control Panel" width="131" height="84" border="0" usemap="#Map2" />
<map name="Map2" id="Map2"><area shape="rect" coords="5,26,121,51" href="contact.php" />
</map></div>
<!--end of mailhead--></div><!--end topbit-->
<div id="mainbody">
<div id="menu">
<ul style="width:870px; font:Arial, Helvetica, sans-serif">
<li style="padding-left:40px;" ><a style="width:54px; padding-left:2px;" href="index.php">Home</a></li>
<li style="padding-left:20px;"><a style="width:104px;" href="contact.php">Contact Us</a></li>
<li style="padding-left:20px;" ><a style="width:134px;" href="http://www.the-bee-scene.com/hostpay">Hosting Packages</a></li>
<li style="padding-right:20px; padding-left:10px;" ><a style="width:104px;" href="design.php">Web Design</a></li>
<li><a style="width:94px;" href="promotion.php">Be Seen!</a></li>
<li ><a style="width:74px;" href="http://www.eXtendcp.com/">Log In</a></li>
<li style="padding-left:30px;"><a style="width:104px;" href="http://www.the-bee-scene.com/hostpay/basket?stay=1">View Basket</a></li>
</ul>
</div><!--end menu-->
<div id="offers">
</div><!--end offers-->
<div class="offers1">
<div align="justify"><span style="font-size:12px">Our focus at Markets2000 is not just about getting a web site on the internet but making its stay there efficient, cost effective and business friendly. Marketing your site begins with how it is designed, monitered and promoted on the web. so we offer two options to get new business going. Choose you build and we offer quality hosting packages, your own domain and a bundle of apps to make the build easy, track and monitor your sites progress. Or if you choose WE-BUILD we can design, develop, monitor and market the site at very competetive prices. Simple! Your choice- Take a look.</span></div><!--end offers1-->
</div>
<div id="leftside"></div><!--end leftside-->
<div id="form">
<?php
if(count($errors) != 0){
echo '<h3>Sorry, please fill in the following text boxes. If not sure put "unsure"</h3>';
echo '<ul>';
foreach ($errors as $error) {
echo '<li>' . $error . '</li>';}echo '</ul>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="400px;" border="1">
<tr>
<td><p><b>What will be the primary function of your web site?</b></p>
<input type="radio" name="primary_function" value "0" id="primary_function" /> A simple Brochure<br/>
<input type="radio" name="primary_function" value "1" id="primary_function" />A site that allows you to add and change content when you wish?<br/>
<input type="radio" name="primary_function" value "2" id="primary_function"/>An E-commerce site?<br/>
<input type="radio" name="primary__function" value "3" id="primary_function"/>A site that will include user membership?<br/></td>
</tr>
<tr>
<td>
<p><b>When would you like the site to go live?</b></p>
<input type="radio" name="go_live" value "0" id="go_live" />One month<br/>
<input type="radio" name="go_live" value "1" id="go_live"/>Two months<br/>
<input type="radio" name="go_live" value "2" id="go_live"/>Three months<br/>
<input type="radio" name="go_live" value "3" id="go_live" />More than three months<br/>
<!--If you have a specific deadline please state it here:
<input type="text" name="live" value="" />--></td>
</tr>
<tr>
<td>
<p><b>What is your type of business, what are are your products and/or services?</b></p>
<textarea name="biz_type" cols="40" rows="5" id="biz_type" > <?php echo htmlspecialchars($_POST['biz_type'],ENT_QUOTES); ?></textarea></td>
</tr>
<tr>
<td>
<p><b>Who is your market?</b> (i.e. teenagers;male,female; animal lovers; artistic people; etc)</p>
<textarea name="market" cols="40" rows="5" id="market" > <?php echo htmlspecialchars($_POST['market'],ENT_QUOTES); ?></textarea></td>
</tr>
<tr>
<td>
<p><b>What style are you looking for?</b> (i.e. if there are any web sites you have seen which reflect the style your site should be like please enter the web address.)</p>
<textarea name="style" cols="40" rows="2" id="style" > <?php echo htmlspecialchars($_POST['style'],ENT_QUOTES); ?></textarea></td>
</tr>
<tr>
<td>
<p><b>What message do you wish to convey to your prospective customers?</b>(i.e. what makes your service or product unique)</p>
<textarea name="message" cols="40" rows="5" id="message" > <?php echo htmlspecialchars($_POST['message'],ENT_QUOTES); ?></textarea></td>
</tr>
<tr>
<td>
<p><b>Does your business have branding guidelines(i.e. logo; type size; colours used in publishing and marketing)</p>
<textarea name="branding" cols="40" rows="5" id="branding" > <?php echo htmlspecialchars($_POST['branding'],ENT_QUOTES); ?></textarea></td>
</tr>
<tr>
<td>
<p><b>What is your budget?</b></p>
<input type="radio" name="budget" value "0" id="budget" />£350<br/>
<input type="radio" name="budget" value "1" id="budget" />£350-£650<br/>
<input type="radio" name="budget" value "2" id="budget" />£650-£1000<br/></td>
</tr>
<tr>
<td>
<p><b>Can you provide your own images of your business re structure, products and services?</b></p>
<input name="images" type="radio" value "0" id="images" />
Yes<br/>
<input type="radio" name="images" value "1" id="images" />No<br/></td>
</tr>
<tr>
<td>
Your name:
<input type="text" size="60" name="name" value=" <?php echo htmlspecialchars($_POST['name'],ENT_QUOTES); ?>" id="name" />
</td>
</tr>
<tr>
<td>
Your email:
<input type="text" size="40" name="email" value=" <?php echo htmlspecialchars($_POST['email'],ENT_QUOTES); ?>" id="email" />
</td>
</tr>
</table>
<tr>
<td>
<input type="submit" name="submit" value="Get your Quote!" />
</td>
</tr>
</form>
</div> <!--end form-->
<div id="Layer5"><img src="myimages/offer2.gif" alt="Domains from 60p per month!!" width="124" height="124" />
<div id="Layer6">
<a href="http://www.the-bee-scene.com/hostpay"><h3 align="center" style="color: #ffffff"> </h3>
</a></div><!--end layer6-->
</div><!--end layer5-->
<div id="Layer10"><img src="myimages/offer2.gif" alt="Marketing applications to get your Business seen!" width="124" height="124" />
<div id="Layer11">
<a href="promotion.php"> <h3 align="center" style="color: #ffffff"> </h3>
</a></div><!--end layer10-->
</div><!--end layer11-->
<div id="Layer8"><img src="myimages/offer2.gif" alt="Small business Hosting packages from £4.99" width="131" height="124" />
<div id="Layer9">
<a href="http://www.the-bee-scene.com/hostpay"><h3 align="center" style="color: #ffffff"> </h3>
</a>
</div><!--end layer8-->
</div><!--end layer9
-------------end Position absolute layers------------------------------------------------------>
</div><!--end mainbody-->
</div><!--end wrapper-->
</body>
</html>
In the database, (I use phpmyadmin) id is the primary key. it also auto-increments. the radio buttons are set at tinyint(1). the text area questions are set at text. Name and email are set at varchar. All are not null. Default is set at none for all.
Bookmarks