I have an index.html file and a savetodatabase.php file. Quite simply I want the form data to store in the db on submit. At the moment nothing happens, no error messages.
In basic_upload there are 5 columns assigned_group, img (not yet implemented), about, and date (not yet implemented). Img and date I haven't completed yet - mostly as i'm still working out file upload and date picker.
Background: I'm running xampp on windows and created the database in phpmyadmin.
Can anyone tell me how to get it to store in the db?
savetodatabase.php
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
$connection = mysql_connect("localhost", "root", ""); // Establishing Connection with Server
$db = mysql_select_db("timelineinfo", $connection); // Selecting Database from Server
if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL
$group = $_POST['group'];
//$img = $_POST['img'];
$about = $_POST['about'];
//$date = $_POST['date'];
if($group !=''||$img !='' ||$date !=''||$about !=''){
//Insert Query of SQL
$query = mysql_query("insert into basic_upload(assigned_group, about) values ('$group', '$about')");
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
}
else{
echo "<p>Insertion Failed <br/> Some Fields are Blank....!!</p>";
}
}
mysql_close($connection); // Closing Connection with Server
?>
</body>
</html>
index.html
<form action="saveToDatabase.php" method="post" >
<p>What group does the event belong to? </p>
<select name="group" class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<h3>Upload a Picture</h3>
//to be completed
<br>
<h3>Description</h3>
<p>Please enter text to describe the achievement (300 Characters Max) </p>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment" name="about" ></textarea>
</div>
<input type="submit" class="btn btn-info" value="Submit Button" name="submit">
</form>