Create a table in a database Create two forms Create separate header and footer
ID: 3825927 • Letter: C
Question
Create a table in a database
Create two forms
Create separate header and footer files
Create a separate style sheet
Create a separate connection script
Form 1: Input form
Form 1 inputs data into the table you created.
Form 1 must contain at least four input fields. It may contain more.
At least one of those input fields must be a dropdown box with at least three choices.
All other input fields must have form handling validation. At the very least you must check to see that fields are neither empty nor null. Users should not be able to submit a form with empty or null fields. More sophisticated validation is optional.
Form 1 must have a header and footer. These files must be called separately.
Form 1 must call a separate database connection script.
Form 1 must be formatted via a separate style sheet.
Form 2: Output form
Form 2 outputs all data from the table you created.
Form 2 must output at least four database fields. It may output more.
Form 2 must have a header and footer. These files must be called separately.
Form 2 must call a separate database connection script.
Form 2 must be formatted via a separate style sheet.
Attachment (Extra Credit!) For extra credit add this functionality to Forms 1 and 2
Table: Include a column that will receive either an attached document or an image.
Form 1: Allow the user to upload either a document or an image into the table you created.
Form 2: Output the attachment.
Optional: Intermediate Webpage
If you chose to process either of your forms through an intermediate webpage, that page must also call header and footer files separately. This page must also be formatted via a separate style sheet.
Not Optional: These Forms MUST work
Your forms must work. They must be functional. I have to be able to see form 1 enter data into a database. Subsequently, I have to see form 2 retrieve that same data from the database, format it and present it on a webpage
Explanation / Answer
Insert.php
</html>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert form</title>
<link type="text/css" media="all" rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Welcome to our Site</h1>
</header>
<div class="main">
<div class= "container">
<aside class="leftAside">
<form action="" method="post" name="insertform">
<p>
<label for="name" id="preinput"> USER NAME : </label>
<input type="text" name="username" required placeholder="Enter your name" id="inputid"/>
</p>
<p>
<label for="email" id="preinput"> EMAIL ID : </label>
<input type="email" name="usermail" required placeholder="Enter your Email" id="inputid" />
</p>
<p>
<label for="mobile" id="preinput"> MOBILE NUMBER : </label>
<input type="text" name="usermobile" required placeholder="Enter your mobile number"
id="inputid" />
</p>
<p>
<label for="mobile" id="preinput">Department : </label>
<select name="subject">
<option value="Computer">Computer</option>
<option value="Maths">Maths</option>
<option value="Physics">Physics</option>
</select>
</p>
<p>
<input type="submit" name="send" value="Submit" id="inputid1" />
</p>
</form>
</aside>
</div>
</div>
<?php
if(isset($_POST['send'])!="")
//print_r($_POST);exit;
{
include("db.php");
$username=mysql_real_escape_string($_POST['username']);
$usermail=mysql_real_escape_string($_POST['usermail']);
$usermobile=mysql_real_escape_string($_POST['usermobile']);
$subject=mysql_real_escape_string($_POST['subject']);
$update=mysql_query("INSERT INTO user(name,email,mobile,subject)VALUES ('$username','$usermail','$usermobile','$subject')");
if($update)
{
$msg="Successfully Inserted!!";
echo "<script type='text/javascript'>alert('$msg');</script>";
header('Location:view.php');
}
else
{
$errormsg="Something went wrong, Try again";
echo "<script type='text/javascript'>alert('$errormsg');</script>";
}
}
?>
<footer>
<p>Created by Bhava shankar.</p>
<a href="mailto:email@yahoo.com">Bhavashankar88@yahoo</a>
</footer>
</body>
</html>
Display.php
<!DOCTYPE html>
<html>
<head>
<title>Result</title>
<link type="text/css" media="all" rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Your Result</h1>
</header>
<div class="main">
<div class= "container">
<aside class="leftAside">
<?php
include('db.php');
$select=mysql_query("SELECT * FROM user order by id desc");
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Email</th>
<th>Mobile</th>
<th>subject</th>
</tr>";
while($userrow=mysql_fetch_array($select)){
echo "<tr>";
echo "<td>" . $userrow['name'] . "</td>";
echo "<td>" . $userrow['email'] . "</td>";
echo "<td>" . $userrow['mobile'] . "</td>";
echo "<td>" . $userrow['subject'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</aside>
</div>
</div>
<footer>
<p>Created by Bhava Shankar.</p>
<a href="mailto:email@yahoo.com">bhavashankar88@yahoo/a>
</footer>
</body>
</html>
DB.php
<?php
ob_start();
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'bhava');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>
Style.css
body
{margin: 0 auto; font-family:black,Verdana,Arial,Helvetica,sans-serif;font-size:12px;background:#042841;color:black;}
header{padding:0;width: 960px;height: 100px;margin: 0 auto;align-content:center;background: #d8e6b3;z-index:100;}
footer{padding:0;width: 960px;height: 100px;margin: 0 auto;align-content:center;background: #d8e6b3;float: left;margin-left: 203px;}
footer p{padding: 12px;}
footer a{padding: 12px;}
aside a:hover{color:#CC9900;}
.main{width:958px; height : 375px;margin: 0 auto; color: #FFFFFF;border: 1px solid red;background-color: #f04242;}
h1{text-align:center;padding: 30px;}
.container{width:400; color: #FFFFFF;margin: 0 auto;}
.content { font-size:10px; color: #CC9900; }
working perfectly if any doubts please let me know
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.