Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $db="sample";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password,$db);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- echo "error";
- }
- echo "Connected successfully";
- if(isset($_POST['submit']))
- $Name=$_POST['name'];
- $age=$_POST['age'];
- $sql = "INSERT INTO Input (Name,age) VALUES ($Name,$age)";
- if (mysqli_query($conn, $sql)) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_close($conn);
- ?>
- <form>
- First name:<br>
- <input type="text" name="name"><br>
- Age:<br>
- <input type="text" name="age">
- <input type="submit" name="Submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement