Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!$_POST) {
- die("No post data!");
- } else {
- $sql = "INSERT INTO " . $_POST['table'] . " (";
- $field_count = (count($_POST) - 1);
- $counter = 1;
- foreach ($_POST as $key => $value) {
- if ($key <> 'table') {
- $sql .= $key;
- if ($counter < $field_count) {
- $sql .= ",";
- }
- }
- $counter += 1;
- }
- $sql .= ") VALUES (";
- $counter = 1;
- foreach ($_POST as $key => $value) {
- if ($key <> 'table') {
- $sql .= "'" . $value . "'";
- if ($counter < $field_count) {
- $sql .= ", ";
- }
- $counter += 1;
- }
- }
- $sql .= ")";
- $result = mysqli_query($_SESSION['dbconn'],$sql);
- if ($result) {
- $_SESSION['message'] = array('info','Record added!');
- } else {
- $_SESSION['message'] = array('warning','Record not added!');
- }
- header("Location: " . SITEHOME);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement