I have this assignment I am trying to solve, I have a piece of code I am trying to run to save my class details on a textfile but the form doesnt write to the text file .. below is the code, i'm a beginner please try enlighten me thank you..
<?php
if(isset($_POST['submit']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$grade = $_POST['grade'];
$email = $_POST['email'];
$file = fopen("schooldetails.txt","a") or die("file not open");
$s = $fname.",".$lname.$age.$sex.$address.$city.$zip.$grade.$email."\n";
fputs($file,$s) or die ("cannot write data");
fclose($file);
}
?>
This above is the php code, while this below is the html code, please help me out on what I might be missing, thank you..
<form action="success.php" method="post">
<fieldset>
<!-- Form Name -->
<legend>Form Name</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="fname">First Name </label>
<div class="col-md-4">
<input id="fname" name="fname" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="lname">Last Name</label>
<div class="col-md-4">
<input id="lname" name="lname" type="text" placeholder="" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="age">Age</label>
<div class="col-md-4">
<input id="age" name="age" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="sex">Sex</label>
<div class="col-md-4">
<input id="sex" name="sex" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="address">Address</label>
<div class="col-md-4">
<input id="address" name="address" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="city">City</label>
<div class="col-md-4">
<input id="city" name="city" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">Email Address</label>
<div class="col-md-4">
<input id="email" name="email" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="zip">Zip</label>
<div class="col-md-4">
<input id="zip" name="zip" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="grade">Grade</label>
<div class="col-md-4">
<input id="grade" name="grade" type="text" placeholder="" class="form-control input-md" required="">
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<button id="submit" name="submit" class="btn btn-primary">submit</button>
</div>
</div>
</fieldset>
</form>