Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername="localhost";
- $username="root";
- $password="";
- $dbname="myDB";
- //Create connection
- $conn= mysqli_connect($servername,$username,$password,$dbname);
- //Check connection
- if(!$conn){
- die("connection failed:".mysqli_connect_error());
- }
- $student_name=$_POST['sName'];
- $Roll=$_POST['rollno'];
- $Class=$_POST['Class'];
- $Section=$_POST['section'];
- $Gender=$_POST['gender'];
- $Email=$_POST['Email'];
- $Mobile=$_POST['Mobile'];
- //insert single rows
- $sql="INSERT INTO students (Name,Roll,Class,Section,gender,Email,Mobile)
- VALUES('$student_name', '$Roll','$Class','$Section','$Gender','$Email','$Mobile')";
- if(mysqli_query($conn,$sql)){
- echo "New record created successfully";
- }else{
- echo"Error:". $sql. "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- ?>
- <!doctype html>
- <!DOCTYPE html>
- <html>
- <body>
- <title>form</title>
- </head>
- <body>
- <form action="insert1.php" method="post">
- <fieldset>
- <legend>Student Information</legend>
- Name:<br>
- <input type="text" name="sName"><br>
- Roll no:<br>
- <input type="text" name="rollno"><br>
- Class:<br>
- <select Name="Class">
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- </select><br>
- Section:
- <select Name="section" size="1">
- <option value="A">A</option>
- <option value="B">B</option>
- <option value="C">C</option>
- <option value="D">D</option>
- <option value="E">E</option>
- <option value="F">F</option>
- <option value="G">G</option>
- <option value="H">H</option>
- </select><br>
- Gender:<br>
- Male:<input type="radio" name="gender" value="male">
- Female:<input type="radio" name="gender" value="female"><br>
- Email:<br>
- <input type="text" name ="Email"><br>
- Mobile number:<br>
- <input type="text" name="Mobile" size="Mobile number"><br>
- </fieldset>
- <input type="submit" value="insert">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement