How to insert data in MySQL using HTML form |
- `first_name`,
- `email`
- `secound-name`
- `phone`, `message`
- `new`
//connection is made with is in lecture 4
PHP CODE
if(isset($_POST["submit"]))
{
$firstname=$_POST['firstname'];
$email=$_POST['email'];
$lastname=$_POST['lastname'];
$phone=$_POST['phone'];
$mess=$_POST['message'];
$query="INSERT INTO `table`(`first_name`, `email`, `secound-name`, `phone`, `message) VALUES ('$firstname','$email','$lastname','$phone','$mess','1')";
$result=mysqli_query($connect,$query);
if(!$result)
{
die("Query failder" . mysqli_error($connect));
}
}
Code Explanation in Lecture 5
Code Explanation in Lecture 5
HTML CODE
<form method="post">
<div class="row form-group">
<div class="col-md-6">
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" class="form-control" placeholder="Your firstname">
</div>
<div class="col-md-6">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" class="form-control" placeholder="Your lastname">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="email">Email</label>
<input type="text" id="email" name="email" class="form-control" placeholder="Your email address">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="subject">phone</label>
<input type="number" id="subject" name="phone" class="form-control" placeholder="Your subject of this message">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="message">Message</label>
<textarea name="message" id="message" name="message" cols="30" rows="10" class="form-control" placeholder="Write us something"></textarea>
</div>
</div>
<div class="form-group">
<input type="submit" name="submit" value="Send Message" class="btn btn-primary">
</div>
<div class="s-12" id="mes"><p id="para"><?php if(isset($error)){ echo("$error");} ?></p></div>
</form>
The explanation is in lecture 5
Previous Lecture Next Lecture
<div class="row form-group">
<div class="col-md-6">
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" class="form-control" placeholder="Your firstname">
</div>
<div class="col-md-6">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" class="form-control" placeholder="Your lastname">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="email">Email</label>
<input type="text" id="email" name="email" class="form-control" placeholder="Your email address">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="subject">phone</label>
<input type="number" id="subject" name="phone" class="form-control" placeholder="Your subject of this message">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="message">Message</label>
<textarea name="message" id="message" name="message" cols="30" rows="10" class="form-control" placeholder="Write us something"></textarea>
</div>
</div>
<div class="form-group">
<input type="submit" name="submit" value="Send Message" class="btn btn-primary">
</div>
<div class="s-12" id="mes"><p id="para"><?php if(isset($error)){ echo("$error");} ?></p></div>
</form>
The explanation is in lecture 5
Previous Lecture Next Lecture
1 Comments
Thanks A Lord For Publish In Your Blog, This Is A Great Things To Learned Many Information. Keep Posting Many Blogs Like This.
ReplyDeleteWeb portal development company in chennai, Web portal development services in chennai
Your Comment is Submitted