Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Build the HTML -->
- <form action="index.php" method="post">
- <input type="text" name="dbname">
- <input type="submit" value="Submit">
- </form>
- <!--Use JS to prevent form resubmission on refresh/back button -->
- <script>
- if ( window.history.replaceState ) {
- window.history.replaceState( null, null, window.location.href );
- }
- </script>
- <?php
- //Set up our variables
- $servername = "localhost";
- $dbname = $_POST["dbname"]; //pull the value from the form
- $username = "utrial";
- $password = "utrial1";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("<p>Connection failed: " . "<span class=\"error\">" . $conn->connect_error . "</span></p>");
- }
- echo "<p>You're currently connected to the database named: <span class=\"success\">$dbname</span></p>";
- ?>
Add Comment
Please, Sign In to add comment