Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- php1.php
- <!DOCTYPE html>
- <html lang="en">
- <?php include('testing.php'); ?>
- <body>
- <div class="panel-body">
- <form action="testing.php" method="post">
- <div class="form-group">
- <label for="name">Name:</label>
- <input type="text" class="form-control" id="txtname">
- </div>
- <div class="form-group">
- <label for="age">Age:</label>
- <input type="text" class="form-control" id="txtage">
- </div>
- <button type="submit" class="btn btn-default" onclick="insertq();">Submit</button>
- </form>
- </div>
- </div>
- </div>
- </body>
- </html>
- php2.php
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $db = "testing";
- // Create connection
- function dbcon(){
- $conn = new mysqli($servername, $username, $password, $db);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully";
- }
- function insertf(){
- echo "adfasdfasdf";
- $sql = "INSERT INTO info (name, age)
- VALUES (//txtname, //txtage)";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- }
- ?>
Add Comment
Please, Sign In to add comment