In this tutorial, we will explain How to insert data into Mysql database using PHP. If you want to save the record in one place then insert the data into the database.
Below Steps:
index.php
<form method="post" action="insert.php" enctype="multipart/form-data"> <div class="name"> <div class="name1"><h1>Student Name:</h1></div> <div class="name2"><input type="text" name="name" value="" /></div> </div> <div class="name"> <div class="name1"><h1>Father Name:</h1></div> <div class="name2"><input type="text" name="father_name" value="" /></div> </div> <div class="name"> <div class="name1"><h1>Mother Name:</h1></div> <div class="name2"><input type="text" name="mother_name" value="" /></div> </div> <div class="name"> <div class="name1"><h1>E-mail:</h1></div> <div class="name2"><input type="email" name="email" value="" /></div> </div> <div class="name"> <div class="name1"><h1>Address:</h1></div> <div class="name2"><textarea name="address"> </textarea></div> </div> <div class="name"> <div class="name1"><h2>DOB:</h2></div> <div class="name2"><input type="text" class="inp" name="dob" value="" /></div> </div> <div class="name"> <div class="name1"><h2>Category:</h2></div> <div class="name3"><input type="radio" name="gender" value="male" /></div><h2 class="cat">male</h2> <div class="name3"><input type="radio" name="gender" value="female"/></div><h2 class="cat">female</h2> </div> <div class="name"> <div class="name1"><h2>Course:</h2></div> <div class="name4"><select name="course"> <option value="BCA">BCA</option> <option value="MCA">MCA</option> <option value="BBA">BBA</option> <option value="DCA">DCA</option> </select></div> </div> <input type="submit" class="sub" name="sub" value="Submit" /> </form>
style.css
.name{ width:100%; min-height:30px; height:auto; float:left; margin-bottom:20px; } .name1{ width:14%; min-height:20px; float:left; height:auto; } .name1 h1{ font-size:18px; font-family:Verdana, Arial, Helvetica, sans-serif; } .name1 h2{ font-size:18px; font-family:Verdana, Arial, Helvetica, sans-serif; margin-top:55px; } .name2{ width:30%; height:30px; float:left; } .name input{ margin-top:10px; height:25px; width:50%; border:#999999 1px solid; border-radius:5px; } .name textarea{ margin-top:10px; height:70px; width:50%; border:#999999 1px solid; border-radius:5px; } .name2 input.inp{ margin-top:50px; } .sub{ margin-top:50px; margin-left:120px; } .name3{ width:3%; height:30px; float:left; margin-top:45px; } .cat{ float:left; font-size:20px; margin-top:55px; } .name4{ width:3%; height:30px; float:left; margin-top:60px; }
insert.php
<?php mysql_connect('localhost', 'root', ''); mysql_select_db('db'); if(isset($_POST['sub']) == 'Submit'){ $name = $_POST['name']; $father_name = $_POST['father_name']; $mother_name = $_POST['mother_name']; $e_mail = $_POST['email']; $add = $_POST['address']; $dob = $_POST['dob']; $category = $_POST['gender']; $courses = $_POST['course']; $query = "insert into new set name='$name', father_name='$father_name', mother_name='$mother_name', address='$add', dob='$dob', e_mail='$e_mail', courses='$courses', category='$category' "; $num =mysql_query($query); } ?>
3 Comments
Anibal Pilbin
May 31, 2020 - 1:13 amHello , i see the your website get very good daily traffic , why donot you make more money by joining >> https://cutt.ly/ads-wordpress , your daily earning will be increased alongside with adsence try it now for few days and see your daily earning >> https://cutt.ly/ads-wordpress
ปั๊มไลค์
May 30, 2020 - 4:54 pmLike!! Really appreciate you sharing this blog post.Really thank you! Keep writing.
Danielfauro
April 11, 2020 - 5:26 amCheck out our customized gifts selection for the very best in unique or custom, handmade pieces from our shops.
Click here to send a Digital Gift to Your Loved Ones.
https://customiss.com