Bootstrap form won't post data into phpmyadmin database - php

My bootstrap form won't post data into the phpmyadmin database, i click submit and nothing is submitted, i have included the configuration file and my form file. The configuration file works with the registration form, so i'm thinking it is to do with my forms. My website is run on hostinger, at www.grademanager.16mb.com . No error messages pop up, when you press submit the page reloads.
UPDATE : I have changed the sql statement to a pdo statement, but it will only insert the first two statements, the student name and first subject into my php my admin database. It won't insert the other two statements.
Also how do i make sure it only goes to thte thanks.html file if the data has been submitted successfully ?
<?php
ob_start();
session_start();
//set timezone
date_default_timezone_set('Europe/London');
//database credentials
define('DBHOST','mysql.hostinger.co.uk');
define('DBUSER','u717042829_mac');
define('DBPASS','********');
define('DBNAME','u717042829_db1');
//application address
define('DIR','http://grademanager.16mb.com/');
define('SITEEMAIL','noreply#grademanager.comlu.com');
try {
//create PDO connection
$db = new PDO("mysql:host=".DBHOST.";port=3306;dbname=".DBNAME, DBUSER, DBPASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
//show error
echo '<p class="bg-danger">'.$e->getMessage().'</p>';
exit;
}
//include the user class, pass in the database connection
include('classes/user.php');
$user = new User($db);
?>
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
require("includes/config.php");
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); }
//define page title
$title = 'Register Past Student';
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Past Student</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<form class="form-horizontal" method="post" action= "">
<fieldset>
<!-- Form Name -->
<legend> Register A Past Student </legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Student Name</label>
<div class="col-md-4">
<input id="name" name="name" type="text" placeholder="First and Last Name" class="form-control input-md" required="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="subject1">Subject 1</label>
<div class="col-md-4">
<select id="subject1" name="subject1" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="grade1">Grade 1</label>
<div class="col-md-4">
<select id="grade1" name="grade1" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="subject2">Subject 2</label>
<div class="col-md-4">
<select id="subject2" name="subject2" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="grade2">Grade 2</label>
<div class="col-md-4">
<select id="grade2" name="grade2" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="subject3">Subject 3</label>
<div class="col-md-4">
<select id="subject3" name="subject3" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="grade3">Grade 3</label>
<div class="col-md-4">
<select id="grade3" name="grade3" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="subject4">Subject 4</label>
<div class="col-md-4">
<select id="subject3" name="subject4" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="grade4">Grade 4</label>
<div class="col-md-4">
<select id="grade1" name="grade4" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Multiple Radios (inline) -->
<div class="form-group">
<label class="col-md-4 control-label" for="attendanc">Attendance %</label>
<div class="col-md-4">
<label class="radio-inline" for="attendanc-0">
<input type="radio" name="attendanc" id="attendanc-0" value="99-100" checked="checked">
99-100
</label>
<label class="radio-inline" for="attendanc-1">
<input type="radio" name="attendanc" id="attendanc-1" value="97-98">
97-98
</label>
<label class="radio-inline" for="attendanc-2">
<input type="radio" name="attendanc" id="attendanc-2" value="95-96">
95-96
</label>
<label class="radio-inline" for="attendanc-3">
<input type="radio" name="attendanc" id="attendanc-3" value="">
93-94
</label>
<label class="radio-inline" for="attendanc-4">
<input type="radio" name="attendanc" id="attendanc-4" value="">
91-92
</label>
<label class="radio-inline" for="attendanc-5">
<input type="radio" name="attendanc" id="attendanc-5" value="">
90 or less
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="form-group">
<label class="col-md-4 control-label" for="gender">Gender</label>
<div class="col-md-4">
<div class="radio">
<label for="gender-0">
<input type="radio" name="gender" id="gender-0" value="Male" checked="checked">
Male
</label>
</div>
<div class="radio">
<label for="gender-1">
<input type="radio" name="gender" id="gender-1" value="Female">
Female
</label>
</div>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" id="submit">Click Submit</label>
<div class="col-md-4">
<button id="singlebutton" type="submit" name="submit" class="btn btn-success">Submit</button>
</div>
</div>
</fieldset>
</form>
<?php
//require("includes/config.php");
if (isset($_POST['name'])) { //checks if the name has posted value then inserts the data
$name = $_POST['name'];
$subject1 = $_POST['subject1'];
$grade1 = $_POST['grade1'];
$subject2 = $_POST['grade2'];
$q = "INSERT INTO paststudent (name, subject1,grade1,subject2) VALUES (:name, :subject1,:grade1,:subject2);"; //sql statement add a colon intead of variables so pdo can prepare the statement and prevent any sql injections
$query = $db ->prepare ($q);
$results = $query ->execute (array(
":name" => $name, //points to the variable
":subject1" => $subject1,
":grade1" => $grade1,
":subject2" => $subject2
));
header ('location:thanks.html');
}
?>
</html>

Error 1:
You missed type="submit"
<button id="singlebutton" type="submit" name="submit" class="btn btn-success">Submit</button
Error 2:
You are mixing all the mysql,mysqli and PDO extensions. Thats why you
are not able to insert into db.
In connection file, You have used PDO. And while inserting, You wrote mysqli but your syntax seems to be for mysql.
Error 3:
Your insert query syntax is incorrect.
$sql = "INSERT INTO paststudent (name,subject1,grade,subject2,grade2,subject2,grade2,subject3,grade3,subject4,grade4,attendance,gender) VALUES ('$_POST[name]','$_POST[subject1]','$_POST[grade1]','$_POST[subject2]','$_POST[grade2]','$_POST[subject3]','$_POST[grade3]','$_POST[subject4]','$_POST[grade4]','$_POST[attendance]','$_POST[gender]')";
You have given 13 coumns and 11 values ...???
Why do you insert the values as is ..???
Why dont you sanitize it???
Are you aware of mysql_injections???

Not sure what effect this will have but I see 2 closing form tags

enter space before param and value
use mysql_query
<?php
require("includes/config.php");
if(isset($_POST['submit'])) {
$sql = "INSERT INTO paststudent (name, subject1, grade, subject2, grade2, subject2, grade2, subject3, grade3, subject4, grade4, attendance ,gender) VALUES ('$_POST[name]', '$_POST[subject1]', '$_POST[grade1]', '$_POST[subject2]', '$_POST[grade2]', '$_POST[subject3]', '$_POST[grade3]', '$_POST[subject4]', '$_POST[grade4]', '$_POST[attendance]', '$_POST[gender]')";
if (mysql_query($sql)) {
echo "succesfully submitted to the database";
} else {
echo "Well this is embarising";
}
}
?>
if not work ، manually execute insert query to database and check the
error

Related

Why isn't $conditions being populated in my PHP code and why can't I pull form data?

everyone! I am making a form consisting of fully drop down selectable menus where the user will populate the field. After pressing the submit form, I plan that information will be pulled from a database to display search results to the user. I am a little new to SQL and PHP, so any help would be appreciated! I attached the form and PHP code separately.
<form autocomplete="on" class="form-horizontal" action="" enctype="multipart/form-data" method="POST" name= "unit_assignments">
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="course_designation" class="col-lg-4 control-label">Course</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="course_designation" id="course_designation">
<option value="" selected disabled>Please Select</option>
<option value="_105">105</option>
<option value="_105i">105i</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="year" class="col-lg-4 control-label">Year</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="year" id="year">
<option value="" selected disabled>Please Select</option>
<option value="_2018">2018</option>
<option value="_2017">2017</option>
<option value="_2016">2016</option>
<option value="_2015">2015</option>
<option value="_2014">2014</option>
<option value="_2013">2013</option>
<option value="_2012">2012</option>
<option value="_2011">2011</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="semester" class="col-lg-4 control-label">Semester</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="semester" id="semester">
<option value="" selected disabled>Please Select</option>
<option value="fall">Fall</option>
<option value="spring">Spring</option>
<option value="summer">Summer</option>
<option value="maymester">Maymester</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="discipline" class="col-lg-4 control-label">Discipline</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="discipline" id="discipline">
<option value="" selected disabled>Please Select</option>
<option value="nat_sciences">Natural Sciences</option>
<option value="health_medicine">Health Medicine</option>
<option value="social_sciences">Social Sciences</option>
<option value="humanities">Humanities</option>
<option value="digital_humanities">Digital Humanities</option>
<option value="law">Law</option>
<option value="business">Business</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="digital_literacy" class="col-lg-4 control-label">Type</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="digital_literacy" id="digital_literacy">
<option value="" selected disabled>Please Select</option>
<option value="podcast">Podcast</option>
<option value="video">Video</option>
<option value="webpage">Webpage</option>
<option value="sparks">Sparks</option>
<option value="illustrator">Illustrator</option>
<option value="in_design">In Design</option>
<option value="canvas">Canvas</option>
<option value="pitochart">Pitochart</option>
<option value="power_point">Power Point</option>
<option value="spreadsheet">Spreadsheet</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="genre" class="col-lg-4 control-label">Genre</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="genre" id="genre">
<option value="" selected disabled>Please Select</option>
<option value="book_review">Book Review</option>
<option value="film_review">Film Review</option>
<option value="play_review">Play Review</option>
<option value="literature_review">Literature Review</option>
<option value="peer_reviewed_journal_articles">Peer Reviewed Journal Article</option>
<option value="conference_paper">Conference Paper</option>
<option value="conference_presentation">Conference Presentation</option>
<option value="grant_proposal">Grant Proposal</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<div class="form-group">
<label for="method" class="col-lg-4 control-label">Method</label>
<div class="col-lg-8">
<select type="hidden" class="form-control" name="method" id="method">
<option value="" selected disabled>Please Select</option>
<option value="archival_research">Archival Research</option>
<option value="textual_analysis">Textual Analysis</option>
<option value="rhetorical_analysis">Rhetorical Analysis</option>
<option value="reviewing_the_literature">Reviewing the Literature</option>
</select>
</div>
</div>
</div>
</div>
<center>
<div class="col-sm-4">
<h4></h4>
<div class="panel panel-default background-light padded">
<center>
<input class="btn btn-primary btn-block" type="submit" value="submit">
</center>
</div>
</div>
</center>
</form>
This is the PHP portion of the code. The page just keeps returning an empty number for conditions and only prints out "SELECT * FROM unit_assignments". It never ends up executing the rest of the code and I was wondering if it was because my PHP code is wrong or my form code. My page does connect to the database, so I don't think there are any database errors.I have tried varying methods of writing the PHP code but to no avail, which leaves me to believe maybe the PHP code and the form just aren't connecting.
<?php
// define the list of fields
$fields = array('course_designation', 'year', 'discipline', 'digital_literacy', 'genre', 'method');
$conditions = array();
// loop through the defined fields
foreach($fields as $field){
// if the field is set and not empty
if(!empty($_POST[$field])) {
// create a new condition while escaping the value inputed by the user (SQL Injection)
$conditions[] = "`$field` LIKE '%" . mysqli_real_escape_string($_POST[$field]) . "%'";
}
}
// }
// builds the query
$query = "SELECT * FROM unit_assignments ";
echo count($conditions);
// if there are conditions defined
if(count($conditions) > 0) {
// append the conditions
$query .= "WHERE " . implode (' AND ', $conditions); // you can change to 'OR', but I suggest to apply the filters cumulative
}
echo "$query";
$result = mysqli_query($mysqli_link, $query);
mysqli_close($mysqli_link);
if(isset($_POST['submit'])) {
while($row = mysqli_fetch_array($result)) {
$course_designation = $row['course_designation'];
$year = $row['year'];
$discipline = $row['discipline'];
$digital_literacy = $row['digital_literacy'];
$genre = $row['genre'];
$method = $row['method'];
echo "Course: $course_designation<br>Year: $year<br>Discipline: $discipline<br>digital_literacy: $digital_literacy<br>Genre: $genre<br>Method: $method<br>";
}
}
?>

PHP upload two files on server, info in mySQL db

I'm finding it nearly impossible to get this upload into mySQL database. The "create_news" file is currently uploading both of my files (file and image) onto my server, but then I receive this error when it tries to insert the information into my mySQL db:
Error: visible, homepage, type, publication_name, publication_url, month, date, year, title, author, summary, full_text, tag_1, tag_2, tag_3, tag_4, tag_5, tag_6, tag_7, image, image_type, image_size, file, file_type, file_size ) VALUES ( 'N', 'N', 'N', '', '', '', '', '', 't', '', '', '', '', '', '', '', '', '', '', '18068-','','0', '8776-','','0')
The upload was inserting into mySQL before I added file uploads. Here is my form page:
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/session.php");?>
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/db_connection.php");?>
<?php session_start();
if($_SESSION["login_user"] != true) {
echo("Access denied!");
exit();
}
?>
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/functions.php");?>
<?php find_selected_news_page(); ?>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Washington Jesuit Adacemy: A high quality and comprehensive middle school for 5th through 8th grade boys from low-income communities in the DC metro area.">
<meta name="keywords" content="">
<meta name="author" content="Washington Jesuit Academy">
<title>Washington Jesuit Academy: About</title>
<link rel="stylesheet" type="text/css" href="https://cloud.typography.com/6113114/6497572/css/fonts.css"/>
<link rel="stylesheet" type="text/css" href="https://cloud.typography.com/683054/7063952/css/fonts.css"/>
<link href="/assets/css/wja.css" rel="stylesheet" type="text/css">
<link href="/assets/css/wja-startup.css" rel="stylesheet">
</head>
<body>
<?php include($_SERVER['DOCUMENT_ROOT']."/includes/navigation.php");?>
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: 'textarea',
theme: 'modern',
plugins: [
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
'save table contextmenu directionality template paste textcolor'
],
content_css: 'css/content.css',
menubar: 'edit view format',
toolbar: 'removeformat | bold italic | bullist numlist outdent indent | link anchor | nonbreaking charmap hr | print preview fullpage | code'
});
</script>
<div class="content">
<div class="block">
<div class="container">
<div id="col-md-12"> <?php echo message(); ?> <?php echo form_errors($errors); ?>
<h2>New article or news item</h2>
<form action="create_news.php" method="post" class="form-horizontal" enctype="multipart/form-data">
<div class="form-group">
<label for="visible" class="col-sm-2 control-label">Published</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="visible" id="visible1" value="N" checked>
No </label>
<label class="radio-inline">
<input type="radio" name="visible" id="visible2" value="Y">
Yes </label>
<p class="small">If ‘Yes’ is selected, the item will be publicly visible on the website as soon as it is saved.</p>
</div>
</div>
<div class="form-group">
<label for="homepage" class="col-sm-2 control-label">Featured on Homepage</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="homepage" id="homepage1" value="N" checked>
No </label>
<label class="radio-inline">
<input type="radio" name="homepage" id="homepage2" value="Y">
Yes </label>
<p class="small">If ‘Yes’ is selected, the item will also be featured on the <strong>homepage</strong>.</p>
</div>
</div>
<div class="form-group">
<label for="type" class="col-sm-2 control-label">Type</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="type" id="type1" value="N" checked>
News </label>
<label class="radio-inline">
<input type="radio" name="type" id="type2" value="A">
President's Blog </label>
</div>
</div>
<div class="form-group">
<label for="publication_name" class="col-sm-2 control-label">Publication Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="publication_name" value="" />
</div>
</div>
<div class="form-group">
<label for="publication_url" class="col-sm-2 control-label">Publication URL</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="publication_url" value="" />
</div>
</div>
<div class="form-group">
<label for="month" class="col-sm-2 control-label">Month</label>
<div class="col-sm-10">
<select class="form-control" name="month">
<option value="">Select Month</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
</div>
<div class="form-group">
<label for="date" class="col-sm-2 control-label">Date</label>
<div class="col-sm-10">
<select class="form-control" name="date">
<option value="">Select Date</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</div>
</div>
<div class="form-group">
<label for="year" class="col-sm-2 control-label">Year</label>
<div class="col-sm-10">
<select class="form-control" name="year">
<option value="">Select Year</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
</select>
</div>
</div>
<div class="form-group">
<label for="title" class="col-sm-2 control-label">Title</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="title" value="" />
</div>
</div>
<div class="form-group">
<label for="author" class="col-sm-2 control-label">Author</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="author" value="" />
<p class="small">If this is a President’s Blog, type <strong>Bill Whitaker, Founding President</strong></p>
</div>
</div>
<div class="form-group margin-t-25">
<label for="summary" class="col-sm-2 control-label">Summary</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="summary" value="" />
</div>
</div>
<div class="form-group margin-t-25">
<label for="full_text" class="col-sm-2 control-label">Full Text</label>
<div class="col-sm-10">
<textarea name="full_text" rows="10" style="width:100%"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Optional Tag(s)</label>
<div class="col-sm-5">
<label class="checkbox m-l">
<input type="checkbox" name="tag_1" value="Y">
Tag 1 </label>
<label class="checkbox m-l">
<input type="checkbox" name="tag_2" value="Y">
Tag 2 </label>
<label class="checkbox m-l">
<input type="checkbox" name="tag_3" value="Y">
Tag 3 </label>
<label class="checkbox m-l">
<input type="checkbox" name="tag_4" value="Y">
Tag 4 </label>
</div>
<div class="col-sm-5">
<label class="checkbox m-l">
<input type="checkbox" name="tag_5" value="Y">
Tag 5 </label>
<label class="checkbox m-l">
<input type="checkbox" name="tag_6" value="Y">
Tag 6</label>
<label class="checkbox m-l">
<input type="checkbox" name="tag_7" value="Y">
Tag 7</label>
</div>
</div>
<div class="form-group"><hr />
<label for="full_text" class="col-sm-2 control-label">Image Upload </label>
<div class="col-sm-10">
<input type="file" name="image" class="mt-3"/>
</div> </div>
<div class="form-group"><hr />
<label for="full_text" class="col-sm-2 control-label">File Upload </label>
<div class="col-sm-10">
<input type="file" name="file" class="mt-3"/>
</div> </div>
<div class="text-right">
<input type="submit" name="submit" class="btn btn-primary m-t-md m-r" value="Create item" />
Cancel</div>
</form>
</div>
</div>
</div>
<?php include($_SERVER['DOCUMENT_ROOT']."/includes/footer.php");?>
<!-- JavaScript -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/toolkit.js"></script>
<script src="../assets/js/application.js"></script>
</div>
</body></html><?php
// Close database connection
if (isset($connection)) {
mysqli_close($connection);
}
?>
And here is my "create" page:
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/session.php");?>
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/db_connection.php");?>
<?php
session_start();
if($_SESSION["login_user"] != true) {
echo("Access denied!");
exit();
}
?>
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/functions.php");?>
<?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/validation_functions.php");?>
<?php
if (isset($_POST['submit'])) {
// Process the form
$visible = mysql_prep($_POST["visible"]);
$homepage = mysql_prep($_POST["homepage"]);
$type = mysql_prep($_POST["type"]);
$publication_name = mysql_prep($_POST["publication_name"]);
$publication_url = mysql_prep($_POST["publication_url"]);
$month = mysql_prep($_POST["month"]);
$date = mysql_prep($_POST["date"]);
$year = mysql_prep($_POST["year"]);
$title = mysql_prep($_POST["title"]);
$author = mysql_prep($_POST["author"]);
$summary = mysql_prep($_POST["summary"]);
$full_text = mysql_prep($_POST["full_text"]);
$tag_1 = mysql_prep($_POST["tag_1"]);
$tag_2 = mysql_prep($_POST["tag_2"]);
$tag_3 = mysql_prep($_POST["tag_3"]);
$tag_4 = mysql_prep($_POST["tag_4"]);
$tag_5 = mysql_prep($_POST["tag_5"]);
$tag_6 = mysql_prep($_POST["tag_6"]);
$tag_7 = mysql_prep($_POST["tag_7"]);
$image = rand(1000,100000)."-".$_FILES['image']['name'];
$image_loc = $_FILES['image']['tmp_name'];
$image_size = $_FILES['image']['size'];
$image_type = $_FILES['image']['type'];
$image_folder="images/";
$file = rand(1000,100000)."-".$_FILES['file']['name'];
$file_loc = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$file_folder="files/";
$image_new_size = $image_size/1024;
$file_new_size = $file_size/1024;
$new_image_name = strtolower($image);
$new_file_name = strtolower($file);
$final_image=str_replace(' ','-',$new_image_name);
$final_file=str_replace(' ','-',$new_file_name);
if(move_uploaded_file($image_loc,$image_folder.$final_image))
if(move_uploaded_file($file_loc,$file_folder.$final_file))
$query = "INSERT INTO `news` (";
$query .= "visible, homepage, type, publication_name, publication_url, month, date, year, title, author, summary, full_text, tag_1, tag_2, tag_3, tag_4, tag_5, tag_6, tag_7, image, image_type, image_size, file, file_type, file_size ";
$query .= ") VALUES (";
$query .= " '{$visible}', '{$homepage}', '{$type}', '{$publication_name}', '{$publication_url}', '{$month}', '{$date}', '{$year}', '{$title}', '{$author}', '{$summary}', '{$full_text}', '{$tag_1}', '{$tag_2}', '{$tag_3}', '{$tag_4}', '{$tag_5}', '{$tag_6}', '{$tag_7}', '{$final_image}','{$image_type}','{$image_new_size}', '{$final_file}','{$file_type}','{$file_new_size}'";
$query .= ")";
$result = mysqli_query($connection, $query);
if ($result) {
// Success
$_SESSION["message"] = "Item created.";
redirect_to("manage_content.php");
} else {
// Failure
//$_SESSION["message"] = "Item creation failed.";
//redirect_to("new_news.php");
echo "Error: " . $query . "<br>" . $result->error;
}
} else {
// This is probably a GET request
redirect_to("new_news.php");
}
?>
<?php
if (isset($connection)) { mysqli_close($connection); }
?>

issue with mysqli php While student info update

I need to update students information.
when i click edit button from students view page it display/retrieve user info correctly.but after that editing when i click update/save it show pharse error.
here is my database.
Database info`s
This is edit.php
<?php
session_start();
if(isset($_SESSION['admin'])){
echo "";
}
else
{
header("location:logout.php");
}
require('dbcon.php');
$hjd=$_GET['s_id'];
/* getting link id from index page*/
$que = "SELECT * FROM stu_info WHERE s_id='".$_GET['s_id']."'"; /*selecting id from database*/
$resu = mysqli_query($conl, $que) or die ( mysqli_error());
$rlk = mysqli_fetch_assoc($resu);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
Edit Profile
</title>
<link rel="stylesheet" href="css/bootstrap.css" />
<script src="js/jquery.min.js">
</script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js">
</script>
<script src="date_picker/datetimepicker_css.js">
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form class="form-horizontal" method="GET" action="edit_action.php">
<input type="hidden" name="new" value="1" />
<input type="text" name="chk" value="<?php echo $rlk['s_id']; ?>" hidden="" />
<fieldset>
<!-- Form Name -->
<legend>
Add Student
</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="f_name">
First Name
</label>
<div class="col-md-4">
<input id="f_name" name="f_name" type="text" value="<?php echo $rlk['f_name'];?> " class="form-control input-md" required="">
<span class="help-block">
Student Name
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="l_name">
Last Name
</label>
<div class="col-md-4">
<input id="l_name" name="l_name" type="text" value="<?php echo $rlk['l_name'];?>" class="form-control input-md" required="">
<span class="help-block">
Maybe Father Name
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="roll_no">
Roll No
</label>
<div class="col-md-4">
<input id="roll_no" name="roll_no" type="number" value="<?php echo $rlk['Roll_no'];?>" value="3215" class="form-control input-md" required="">
<span class="help-block">
Student Roll Number
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="dob">
Date Of Birth
</label>
<div class="col-md-4">
<input id="demo1" name="dob" type="text" value="<?php echo $rlk['dob'];?>" class="form-control input-md" required="" onclick="javascript:NewCssCal ('demo1','yyyyMMdd','','','','','')" style="cursor:pointer"/>
<span class="help-block">
Date Of Birth
</span>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="cls">
Select Class
</label>
<div class="col-md-4">
<select id="cls" name="cls" class="form-control">
<option value="1">
class 1
</option>
<option value="2">
class 2
</option>
<option value="3">
class 3
</option>
<option value="4">
class 4
</option>
<option value="5">
class 5
</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="Gender">
Select Gender
</label>
<div class="col-md-4">
<select id="gender" name="gender" class="form-control">
<option value="male">
male
</option>
<option value="femala">
female
</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="reli">
Religion
</label>
<div class="col-md-4">
<select id="reli" name="reli" class="form-control">
<option value="Hindhu">
Hindhu
</option>
<option value="Christian">
Christian
</option>
<option value="Muslim">
Muslim
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="reli">
Community
</label>
<div class="col-md-4">
<select id="commu" name="commu" class="form-control">
<option value="OC">
OC
</option>
<option value="BC" >
BC
</option>
<option value="MBC">
MBC
</option>
<option value="SC">
SC
</option>
<option value="ST">
ST
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="reli">
Blood Group
</label>
<div class="col-md-4">
<select id="blg" name="blg" class="form-control">
<option value="A Possitive">
A Possitive
</option>
<option value="A Negative" >
A Negative
</option>
<option value="A1 Possitive">
A1 Possitive
</option>
<option value="A1 Negative">
A1-
</option>
<option value="A1B Possitive">
A1B Possitive
</option>
<option value="A1B Negative">
A1B Negative
</option>
<option value="A2 Possitive">
A2 Possitive
</option>
<option value="A2 Negative">
A2 Negative
</option>
<option value="A1B Possitive">
A1B Possitive
</option>
<option value="A2B\+">
A2B+
</option>
<option value="A2B Negative">
A2B Negative
</option>
<option value="AB Possitive">
AB Possitive
</option>
<option value="AB Negative">
AB Negative
</option>
<option value="B Possitive">
B Possitive
</option>
<option value="B Negative">
B Negative
</option>
<option value="O Possitive">
O Possitive
</option>
<option value="O Negative">
O Negative
</option>
</select>
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="address">
Address
</label>
<div class="col-md-4">
<textarea class="form-control" id="address" required="" value="<?php echo $rlk['address'];?>" name="address">
default Address
</textarea>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="loc">
Location
</label>
<div class="col-md-4">
<input id="loc" name="loc" type="text" required="" value="<?php echo $rlk['loc'];?>" class="form-control input-md" required="">
<span class="help-block">
currently living in
</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="mobile">
Mobile
</label>
<div class="col-md-4">
<input id="phone" name="phone" type="number" value="<?php echo $rlk['phone'];?>" class="form-control input-md" required="">
<span class="help-block">
Mobile Number
</span>
</div>
</div>
<button type="submit" class="btn btn-primary" name="btn-save" id="btn-save">
<span class="glyphicon glyphicon-plus">
</span> Save this Record
</button>
</fieldset>
</form>
</body>
</html>
Kindly correct error please
Thanks in Advance
This Is Edit Action.php file which is save/update database :
<?php
$status = "";
require('dbcon.php');
if(isset($_GET['new']) && $_GET['new']==1)
{
/*Detecting Input Start */
$s_id =$_GET['chk'];
$f_name = $_GET['f_name'];
$l_name = $_GET['l_name'];
$dob = $_GET['dob'];
$rln = $_GET['roll_no'];
$cls = $_GET['cls'];
$gender = $_GET['gender'];
$address= $_GET['address'];
$reli = $_GET['reli'];
$commu = $_GET['commu'];
$loc = $_GET['loc'];
$phone = $_GET['phone'];
$blg = $_GET['blg'];
/*Detection Input End */
$update=UPDATE `school`.`stu_info` SET `Roll_no` = "$rln", `f_name` = "$f_name", `l_name` = "$l_name", `dob` = "$dob", `std` = "$cls", `gender` = "$gender", `address` = "$address", `loc` = "$loc", `phone` = "$phone", `blg` = "$blg", `commu` = "$commu" WHERE `stu_info`.`s_id` = "$s_id";
$df=mysqli_query($conl,$update);
if(!df){
echo "error";
}
else {
echo "success";
}
}
?>
Kindly Help me By Findout Error
Thanks In Advance
///I Updated My Recent Code
Still Not work Show error
Your code is very unsafe. E. g. reading directly from $_GET array is not recommended. Please consider using PDO with execute to increase security
else {
$update= 'UPDATE `school`.`stu_info` SET `Roll_no` = "$rln", `f_name` = "$f_name", `l_name` = "$l_name", `dob` = "$dob", `std` = "$cls", `gender` = "$gender", `address` = "$address", `loc` = "$loc", `phone` = "$phone", `blg` = "$blg", `commu` = "$commu" WHERE `stu_info`.`s_id` = "$s_id"';
$df=mysqli_query($conl,$update);
} // missing !
Line 25 should be
$update = "UPDATE `school` . `stu_info` SET `Roll_no` = '$rln', `f_name` = '$f_name', `l_name` = '$l_name', `dob` = '$dob', `std` = '$cls', `gender` = '$gender', `address` = '$address', `loc` = '$loc', `phone` = '$phone', `blg` = '$blg', `commu` = '$commu' WHERE `stu_info` . `s_id` = '$s_id''";
and you are missing a } at the end.
But please do not create the queries like this.
This issue is explained here mysql extension deprecated

Uncaught exception 'PDOException', my forms won't post to my phpmyadmin database

Hi i keep on getting this error when i go to post a form.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'attendanc' in 'field list'' in /home/u717042829/public_html/paststudent.php:273 Stack trace: #0 /home/u717042829/public_html/paststudent.php(273): PDOStatement->execute(Array) #1 {main} thrown in /home/u717042829/public_html/paststudent.php on line 273
I'm not sure what is wrong with my code.
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
require("includes/config.php");
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); }
//define page title
$title = 'Register Past Student';
?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Past Student</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<form class="form-horizontal" method="post" action= "">
<fieldset>
<!-- Form Name -->
<legend> Register A Past Student </legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Student Name</label>
<div class="col-md-4">
<input id="name" name="name" type="text" placeholder="First and Last Name" class="form-control input-md" required="">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="subject1">Subject 1</label>
<div class="col-md-4">
<select id="subject1" name="subject1" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="grade1">Grade 1</label>
<div class="col-md-4">
<select id="grade1" name="grade1" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="subject2">Subject 2</label>
<div class="col-md-4">
<select id="subject2" name="subject2" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="grade2">Grade 2</label>
<div class="col-md-4">
<select id="grade2" name="grade2" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="subject3">Subject 3</label>
<div class="col-md-4">
<select id="subject3" name="subject3" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="grade3">Grade 3</label>
<div class="col-md-4">
<select id="grade3" name="grade3" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="subject4">Subject 4</label>
<div class="col-md-4">
<select id="subject3" name="subject4" class="form-control">
<option value="Chemistry">Chemistry</option>
<option value="Computing">Computing</option>
<option value="Economics">Economics</option>
<option value="Further Maths">Further Maths</option>
<option value="Physics">Physics</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="grade4">Grade 4</label>
<div class="col-md-4">
<select id="grade1" name="grade4" class="form-control">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="U">U</option>
</select>
</div>
</div>
<!-- Multiple Radios (inline) -->
<div class="form-group">
<label class="col-md-4 control-label" for="attendanc">Attendance %</label>
<div class="col-md-4">
<label class="radio-inline" for="attendanc-0">
<input type="radio" name="attendanc" id="attendanc-0" value="99-100" checked="checked">
99-100
</label>
<label class="radio-inline" for="attendanc-1">
<input type="radio" name="attendanc" id="attendanc-1" value="97-98">
97-98
</label>
<label class="radio-inline" for="attendanc-2">
<input type="radio" name="attendanc" id="attendanc-2" value="95-96">
95-96
</label>
<label class="radio-inline" for="attendanc-3">
<input type="radio" name="attendanc" id="attendanc-3" value="">
93-94
</label>
<label class="radio-inline" for="attendanc-4">
<input type="radio" name="attendanc" id="attendanc-4" value="">
91-92
</label>
<label class="radio-inline" for="attendanc-5">
<input type="radio" name="attendanc" id="attendanc-5" value="">
90 or less
</label>
</div>
</div>
<!-- Multiple Radios -->
<div class="form-group">
<label class="col-md-4 control-label" for="gender">Gender</label>
<div class="col-md-4">
<div class="radio">
<label for="gender-0">
<input type="radio" name="gender" id="gender-0" value="Male" checked="checked">
Male
</label>
</div>
<div class="radio">
<label for="gender-1">
<input type="radio" name="gender" id="gender-1" value="Female">
Female
</label>
</div>
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" id="submit">Click Submit</label>
<div class="col-md-4">
<button id="singlebutton" type="submit" name="submit" class="btn btn-success">Submit</button>
</div>
</div>
</fieldset>
</form>
<?php
//require("includes/config.php");
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if (isset($_POST['name'])) { //checks if the name has posted value then inserts the data
$name = $_POST['name'];
$subject1 = $_POST['subject1'];
$grade1 = $_POST['grade1'];
$subject2 = $_POST['subject2'];
$grade2 = $_POST['grade2'];
$subject3 = $_POST['subject3'];
$grade3 = $_POST['grade3'];
$subject4 = $_POST['subject4'];
$grade4 = $_POST['grade4'];
$attendanc = $_POST['attendanc'];
$gender = $_POST['gender'];
$q = "INSERT INTO paststudent (name,subject1,grade1,subject2,grade2,subject3,grade3,subject4,grade4,attendanc,gender) VALUES (:name, :subject1,:grade1,:subject2,:grade2,:subject3,:grade3,:subject4,:grade4,:attendanc,:gender);"; //sql statement add a colon intead of variables so pdo can prepare the statement and prevent any sql injections
$query = $db ->prepare ($q);
$results = $query ->execute (array(
":name" => $name, //points to the variable
":subject1" => $subject1,
":grade1" => $grade1,
":subject2" => $subject2,
":grade2" => $grade2,
":subject3" => $subject3,
":grade3" => $grade3,
":subject4" => $subject4,
":grade4" => $grade4,
":attendanc" => $attendanc,
":gender" => $gender
));
}
?>
It's pretty clear what's wrong.
MySQL is returning an error. And MySQL is telling you that the column attendanc is not a valid column in paststudent.
Take a look at the column list in your INSERT statement, and compare that to the the names of the columns in the table. (I suspect you've left off an e from the name of the column... attendance, but that's just a guess, since we don't see the table definition.)

Add A File Attachment to A PHP Email Form Send

Currently I have created a form on a PHP form that posts to the send PHP code. All of the textareas/fields ETC work fine. The issue I have is that I have 3 file fields. The aim is to add 3 file attachments to the email. I just cant work out how to do it.
(Attachment areas at the bottom of the form)
<form method="post" action="quote_send.php">
<form class="form-light mt-20" role="form">
<div class="form-group">
<label>Title</label><br />
<select name="Title">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
</select>
</div> <div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Forename</label>
<input type="text" class="form-control" name="forename" placeholder="Your Forename">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Surname</label>
<input type="text" class="form-control" name="surname" placeholder="Your Surname">
</div>
</div>
</div>
<!----CONTACT DETAILS------>
<h3>Your Contact Details</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Email Address</label>
<input type="text" class="form-control" name="visitormail" placeholder="Your Email Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control" name="number" placeholder="Your Contact Number">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 1</label>
<input type="text" class="form-control" name="address1" placeholder="Address Line 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 2</label>
<input type="text" class="form-control" name="address2" placeholder="Address Line 2">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="city" placeholder="City">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Post Code</label>
<input type="text" class="form-control" name="pcode" placeholder="Post Code">
</div>
</div>
</div>
<!----SITE DETAILS----->
<h3>Site Contact Details</h3>
<div class="form-group">
<label>Title</label><br />
<select name="siteTitle">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Site Contact Forename</label>
<input type="text" class="form-control" name="scforename" placeholder="Site Contact Forename">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Site Contact Surname</label>
<input type="text" class="form-control" name="scsurname" placeholder="Site Contact Surname">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Email Address</label>
<input type="text" class="form-control" name="scvisitormail" placeholder="Site Email Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control" name="scnumber" placeholder="Site Contact Number">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 1</label>
<input type="text" class="form-control" name="scaddress1" placeholder="Site Address Line 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 2</label>
<input type="text" class="form-control" name="scaddress2" placeholder="Site Address Line 2">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="sccity" placeholder="City">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Post Code</label>
<input type="text" class="form-control" name="scpcode" placeholder="Post Code">
</div>
</div>
</div>
<!----SITE DETAILS----->
<h3>Site Details</h3>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>Number of Domestic Plots</label><br />
<select name="numdp">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5+">5+</option>
</select></div></div>
<div class="col-md-2">
<div class="form-group">
<label>Number of Commercial Plots</label><br />
<select name="numcp">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5+">5+</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Is The Site Visit Required?</label><br />
<select name="sitevisitr">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>Is The Site a Brownfield/Regeneration?</label><br />
<select name="brownregen">
<option value="Brownfield">Brownfield</option>
<option value="Regeneration">Regeneration</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>Is The Site Contaminated?</label><br />
<select name="contam">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Property Type</label><br />
<select name="proptype">
<option value="Commercial">Commercial</option>
<option value="Flat">Flat</option>
<option value="Detached">Detached</option>
<option value="Semi-Detached">Semi-Detached</option>
<option value="Terraced">Terraced</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Rooms In The Property</label><br />
<select name="nrooms">
<option value="N/A">N/A</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Do You Have A Gas Supplier? *</label><br />
<select name="gsupplier">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>If Yes. Who Is Your Gas Supplier?</label>
<input type="text" class="form-control" name="gsuppliername" placeholder="Gas Supplier">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Who Will Be Carrying Out The Excavation?</label><br />
<select name="erxcav">
<option value="MDL">MDL</option>
<option value="Customer">Customer</option>
</select>
</div></div>
<br /><p> * NOTE: If you do not have a gas supplier in place, you will need to obtain one before any works can be carried out. You can find a gas supplier here.</p>
<div class="col-md-2">
<div class="form-group">
<label>What Service Do You Require?</label><br />
<select name="servicer">
<option value="Gas Connection(s)">Gas Connection(s)</option>
<option value="Gas Disconnection(s)">Gas Disconnection(s)</option>
<option value="Meter Fitting / Exchange">Meter Fitting / Exchange</option>
<option value="Directional Drilling">Directional Drilling</option>
<option value="Outlet Pipework">Outlet Pipework</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>What Is Your Hourly Load? (KWh)</label>
<input type="text" class="form-control" name="hourl" placeholder="Hourly Load (KWh)">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>What Is Your Annual Load? (KWh)</label>
<input type="text" class="form-control" name="annl" placeholder="Annual Load? (KWh)">
</div>
</div> <br /><br /><br /><br />
<p> * NOTE: We require specific documents so we can proceed with your quote. These documents can be seen in the upload section below</p>
<div class="col-md-4">
<div class="form-group">
<label>Scaled Site Location Plan</label>
<input name="sslp" type="file">
</div></div>
<div class="col-md-4">
<div class="form-group">
<label>Domestic Property Schedule</label>
<input name="dps" type="file">
</div></div>
<div class="col-md-4">
<div class="form-group">
<label>Site Boundary Drawing</label>
<input name="sbd" type="file">
</div></div>
<p> * NOTE: We require specific documents so we can proceed with your quote. These documents can be seen in the upload section below</p>
<div class="col-md-6">
<div class="form-group">
<label>Is There Any Other Information You Think Would Help Us?</label><br />
<textarea class="form-control" name="notes" placeholder="Write you message here..." style="height:100px;"></textarea>
</div></div>
</div>
<br / >
<button type="submit" class="btn btn-two">SUBMIT</button>
</form>
THE PHP send code.-----------------------
<?php
$Title = $_POST['Title'];
$forename = $_POST['forename'];
$surname = $_POST['surname'];
$visitormail = $_POST['visitormail'];
$number = $_POST['number'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$pcode = $_POST['pcode'];
$siteTitle = $_POST['siteTitle'];
$scforename = $_POST['scforename'];
$scsurname = $_POST['scsurname'];
$scvisitormail = $_POST['scvisitormail'];
$scnumber = $_POST['scnumber'];
$scaddress1 = $_POST['scaddress1'];
$scaddress2 = $_POST['scaddress2'];
$sccity = $_POST['sccity'];
$scpcode = $_POST['scpcode'];
$numdp = $_POST['numdp'];
$numcp = $_POST['numcp'];
$sitevisitr = $_POST['sitevisitr'];
$brownregen = $_POST['brownregen'];
$contam = $_POST['contam'];
$proptype = $_POST['proptype'];
$nrooms = $_POST['nrooms'];
$gsupplier = $_POST['gsupplier'];
$gsuppliername = $_POST['gsuppliername'];
$erxcav = $_POST['erxcav'];
$servicer = $_POST['servicer'];
$hourl = $_POST['hourl'];
$annl = $_POST['annl'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$sslp = $_POST['sslp'];
$dps = $_POST['dps'];
$sbd = $_FILES['sbd'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"#") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($forename) || empty($visitormail) || empty($notes )) {
echo "<h2>You have missed out required fields, please go back to them and fill them in</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = "New $servicer Quote Request";
$notes = stripcslashes($notes);
$message = "Section 1 - Customer Details \n
Customer Title: $Title
Customer Forname: $forename
Customer Surname: $surname
Customer Email: $visitormail
Customer Contact Number: $number
Contact Postal Address:\n $address1 \n $address2 \n $city \n $pcode \n
Section 2 - Site Contact Details \n
Site Contact Title: $siteTitle
Site Contact Forname: $scforename
Site Contact Surname: $scsurname
Site Contact Email Address: $scvisitormail
Site Contact Number: $scnumber
Site Current Postal Address:\n $scaddress1 \n $scaddress2 \n $sccity \n $scpcode \n
Section 3 - Site Work Details \n
Number of Domestic Plots: $numdp
Number of Commercial Plots: $numcp
Site Visit Required: $sitevisitr
Site a Brownfield/Regeneration: $brownregen
Site Contaminated: $contam
Property Type: $proptype
Number of Rooms in The Property: $nrooms
Gas Supplier Organised: $gsupplier
Gas Supplier Name: $gsuppliername
Who Will Be Carrying Out The Excavation: $erxcav
Service Rquired: $servicer
Hourly Load: $hourl
Annual Load: $annl
Extra Information: $notes
Attached Files: $sslp \n $dps \n $sbd
Please reply to this email within 24 hours to maximise our chances of turning enquiries in to sales.
";
$_FILES ="$sbd";
$from = "From: $visitormail\r\n";
mail("ash.manterfield#btinternet.com", $subject, $message, $from, $_FILES);
?>
</span>Thank you <?php echo $visitor ?> for contacting us regarding <?php echo $attn ?>.
Any help would be appreciated I've tried a few approaches and cant work out how to do it.

Categories