Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET["submit"])) {
- }
- $host = "localhost";
- $user = "root";
- $password = "password";
- $database = "test";
- // Establish server connection and select database
- $dbh = mysqli_connect($host, $user, $password, $database);
- if (mysqli_connect_errno()) {
- die('Unable to connect to database ' . mysqli_connect_error());
- }
- else {
- $text = trim($_POST['serial']);
- $textAr = explode("n", $text);
- $textAr = array_filter($textAr, 'trim'); // remove any extra r chars
- foreach ($textAr as $line) {
- $query = mysqli_query($dbh, "SELECT serials FROM `wp27_test6serial` WHERE `serials` = '$line'");
- $result = mysqli_query($dbh, $query);
- if (mysqli_num_rows($result) > 0) {
- die('entry already exists');
- }
- else {
- $query = mysqli_query($dbh, "INSERT INTO wp27_test6serial (rtxserials) VALUES ('$line')");
- echo ('serials submitted');
- }
- }
- }
Add Comment
Please, Sign In to add comment