Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername= "localhost";
- $username= "root";
- $password="";
- $dbname="bit2018";
- $msg='';
- //create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- //check connection
- if(!$conn)
- {
- die("Connection failed:" . mysqli_connect_error());
- }
- if(isset($_POST['submitbtn']))
- {
- $std_fname= $_POST['std_fname'];
- $std_lname= $_POST['std_lname'];
- $std_roll= $_POST['std_roll'];
- $std_contact= $_POST['std_contact'];
- $std_address= $_POST['std_address'];
- $sqlQuery = "INSERT INTO student_3rd(std_fname, std_lname, std_roll, std_contact, std_address)
- VALUES('$std_fname','$std_lname','$std_roll','$std_contact','$std_address')";
- if(mysql_query($conn,$sqlQuery))
- {
- $msg = "Information Inserted Successfully";
- }
- else
- {
- $msg = "Problem in inserting data";
- }
- }
- ?>
- <h1 style = "color:green"><?php echo $msg;?></h1>
- <fieldset>
- <legend>student info form</legend>
- <form method = "POST">
- <b>First Name:</b><input type="text" name="std_fname" required>
- <hr>
- <b>Last Name:</b><input type="text" name="std_lname" required>
- <hr>
- <b>Roll:</b><input type="text" name="std_roll" required>
- <hr>
- <b>Contact:</b><input type="text" name="std_contact" required>
- <hr>
- <b>Address:</b><input type="text" name="std_address" required>
- <hr>
- <button type="submit" name="submitbtn"> Save</button>
- </form>
- </fieldset>
Add Comment
Please, Sign In to add comment