I am new to web designing and i just got an assignment from my class to create a jQuery application. the application will require a user to submit a data that should be saved to a database! My friend told me that when i have created the php connection, i should save them bothe the HTML and PHP files in the database mysql folder, i use xampp as my mysql server.
Now the problem is once i click the submit button, the page loads but does not display anything and the data isnt uploaded to the database. How can i handle this to successfully upload my data to the database?
Here is my html file with the form
<form action="con.php" method="POST" enctype="multipart/form-data">
<div style="padding:20px 20px;">
<h2>Personal Details</h2>
<p>In this section, we would like you to provide your personal details.</p>
<label for="name">Name:</label>
<input type="text" name="fullname" placeholder="enter your fullname" data-theme="a" required/>
<label for="PhoneNumber">Phone Number:</label>
<input type="number" name="phonenumber" placeholder="enter your phone number" data-theme="a" required/>
<label for="mail">E-Mail:</label>
<input type="text" name="email" value=""placeholder="enter your e-mail address" data-theme="a" required/>
<div data-role="controlgroup" data-type="horizontal" data-mini="true" required/>
<h4>Gender</h4>
<input type="radio" name="gender" value="f" id="gender" required/>
<label for="gender">Female</label>
<input type="radio" name="gender" value="m" id="gender2" required/>
<label for="gender2">Male</label>
</div>
<h2>Description</h2>
<p>Provide in detail the description of the case you are reporting and to where it took place.</p>
<label for="location">Location</label>
<input type="text" name="location" placeholder="enter where you are reporting from" data-theme="a" required/>
<label for="title">Title:</label>
<input type="text" name = "title" id="title" value=""placeholder="enter the title of the case you are reporting" data-theme="a" required/>
<label for="description">Description:</label>
<textarea cols="40" rows="8" name = "description" id = "textarea" value=""placeholder="describe the case you are reporting" required/></textarea>
<div data-role="fieldcontain">
<label for="picture">Upload a picture or a video file for evidence: </label>
<input type="file" name = "image" id="picture" id="picture" required/>
</div>
<div data-role="fielcontain">
<label for="terms">Before you proceed, please read to Terms and Conditions applied. Click <a href="#page3">here</a> to read the terms and conditions</label>
<select name="terms" id="terms" data-role="slider" data-mini="true">
<option name = "terms" value="n">Deny</option>
<option name = "terms" value="y">Agree</option>
</select>
</div>
</div>
<div data-role="fieldcontain">
<input type="submit" name = "register" value="Send"/>
</div>
</form>
And here is my PHP file
<?php
if(isset($_POST['register'])){
$fullname = $_POST['fullname'];
$phonenumber = $_POST['phonenumber'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$location = $_POST['location'];
$title = $_POST['title'];
$description = $_POST['description'];
$image = $_POST['image'];
$terms = $_POST['terms'];
//database connection
$conn = new mysqli('localhost','root','','reportapp');
//check connection
if($conn->connect_error){
die('connection failed'.$conn->connect_error);
echo "report failed";
} else{
$stmt = $conn->prepare("insert into trials(fullname,phonenumber,email,gender,location,title,description,image,terms)
values (?,?,?,?,?,?,?,?,?) ");
$stmt->bind_param("sisssssbs", $fullname, $phonenumber, $email,$gender, $location, $title, $description, $image, $terms) ;
$stmt->execute();
echo "case report success.....";
$stmt->close();
$conn->close();
}
}
?>
When ever i upload the data, it does not display the successfully message but only show a blank white page and the data is not inserted into thee database please help me how i can successfully upload the form data to the database!