I am trying to insert into table with PHP and MySQL but the page only refresh it self when i press the button.

I haven't done debugging, i have an IF statement that displays any errors that fires if the SQL query have errors. But the thing is even the trigger_error doesnt return anything back to me so i can see whats the problem is.

I never come to this kind of problem before and i have no left ideas in my head so i can fix this.

`

<?php

        if(isset($_POST["submitGirl"])) {
            $name = $_POST['girlName'];
            $url = $_POST['instaProfLink'];
            $profilepic = $_POST['profilepic'];
            $pic1 = $_POST["pic1"];
            $pic2 = $_POST["pic2"];
            $pic3 = $_POST["pic3"];
            $pic4 = $_POST["pic4"];
            $pic5 = $_POST["pic5"];
            $tags = $_POST["tags"];

            $sql = "INSERT INTO modelprofile VALUES ('', '".htmlentities($name)."', '".htmlentities($url)."', '".htmlentities($profilepic)."', '".htmlentities($pic1)."', '".htmlentities($pic2)."', '".htmlentities($pic3)."', '".htmlentities($pic4)."', '".htmlentities($pic5)."', '".htmlentities($tags)."')";
            $result = $conn->query($sql);
            if($result === false) {
                trigger_error("A required file did not exist!", E_USER_ERROR);
                trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
            } else {
                echo "model added";
            }
        }
    ?>

submitGirl is the name of the button. When user press, it should add the rest info into database table, from the fields above

Recommended Answers

All 12 Replies

  1. Are you entirely sure that there are ten columns in the model profile table, listed in order of the columns specified, and with the appropriate filed types (e.g. the columns storing pictures should be blobs, etc.)?

  2. Instead of using htmlentities surrounded by manual single quotes, use $conn->real_escape_string($string) as so:

     $sql = "INSERT INTO modelprofile VALUES (
        '',
        " . $conn->real_escape_string($name) . ",
        " . $conn->real_escape_string($url) . ",
        " . $conn->real_escape_string($profilepic) . ",
        " . $conn->real_escape_string($pic1) . ",
        " . $conn->real_escape_string($pic2) . ",
        " . $conn->real_escape_string($pic3) . ",
        " . $conn->real_escape_string($pic4) . ",
        " . $conn->real_escape_string($pic5) . ",
        " . $conn->real_escape_string($tags) . "
    )";
  3. If the MySQL query isn't running, and it's not triggering an error, and also not spitting out "model added", it's possible the entire if block if(isset($_POST["submitGirl"])) is not being triggered. Try running an else around that if statement to see if $_POST['submitGirl'] doesn't exist.

You posted this same question to stackoverflow, where you received what I would consider very helpful suggestions, which are pretty much in line with what Dani is suggesting: debug your code.

Running your code (including the form you edited out of your stackoverflow post), I see the following output after submitting an empty form. I excluded the actual execution of the query because I was too lazy to create a database and table for you.

var_dump($_POST):
array (size=9)
'instaProfLink' => string '' (length=0)
'girlName' => string '' (length=0)
'pic1' => string '' (length=0)
'pic2' => string '' (length=0)
'pic3' => string '' (length=0)
'pic4' => string '' (length=0)
'pic5' => string '' (length=0)
'tags' => string '' (length=0)
'submitGirl' => string 'Submit Query' (length=12)

echo isset($_POST['submitGirl']): 1

( ! ) Warning: Undefined array key "profilepic" in /index.php on line 11

( ! ) Deprecated: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated in /index.php on line 20

echo $sql: INSERT INTO modelprofile VALUES ('', '', '', '', '', '', '', '', '', '', '1')

And this is the code I 'rescued' and cleaned up from your stackoverflow post:

<?php
// require "../core/core.php";

var_dump($_POST);

echo isset($_POST["submitGirl"]);

if (isset($_POST["submitGirl"])) {
    $name       = $_POST['girlName'];
    $url        = $_POST['instaProfLink'];
    $profilepic = $_POST['profilepic'];
    $pic1       = $_POST["pic1"];
    $pic2       = $_POST["pic2"];
    $pic3       = $_POST["pic3"];
    $pic4       = $_POST["pic4"];
    $pic5       = $_POST["pic5"];
    $tags       = $_POST["tags"];
    $havenude   = 1;

    $sql    = "INSERT INTO modelprofile VALUES ('', '" . htmlentities($name) . "', '" . htmlentities($url) . "', '" . htmlentities($profilepic) . "', '" . htmlentities($pic1) . "', '" . htmlentities($pic2) . "', '" . htmlentities($pic3) . "', '" . htmlentities($pic4) . "', '" . htmlentities($pic5) . "', '" . htmlentities($tags) . "', '" . htmlentities($havenude) . "')";

    // $result = $conn->query($sql);
    // if ($result === false) {
    //     trigger_error("A required file did not exist!", E_USER_ERROR);
    //     trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
    // } else {
    //     echo "model added";
    // }

    echo $sql;
}

?>
<!doctype html>
<html lang="en-US">
<body style="font-family: monospace;">
<!-- Page Content -->
<div class="container">
    <form action="index.php" method="POST">
        <div class="row">
            <div class="col-lg-12 text-center">
                <h3 class="mt-5">Copy the URL <font color="red">username</font> of the girl. Example:
                    instagram.com/[<font color="red">xenia</font>]</h3>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">https://instagram.com/</span>
                    </div>
                    <input type="text" placeholder="xenia" name="instaProfLink" class="form-control" id="basic-url"
                           aria-describedby="basic-addon3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">Girl Name</span>
                    </div>
                    <input type="text" placeholder="Full Name" name="girlName" class="form-control" id="basic-url"
                           aria-describedby="basic-addon3">
                </div>
                <p class="lead">Add the images from the girl profile <b>(NOT REQUIRED)</b></p>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic1" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic2" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic3" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic4" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic5" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">TAGS</span>
                    </div>
                    <input type="text" name="tags" placeholder="separate with , " class="form-control" id="basic-url"
                           aria-describedby="basic-addon3">
                </div>
                <input type="submit" name="submitGirl" class="btn btn-outline-success btn-lg btn-block"/>
            </div>
        </div>
    </form>

</body>
</html>

Hope this helps!

You can visit the website at https://leakedof.us/admin/index.php
the current code i have is like this

I have edited it but still doesnt give an info error i dont understand what is happening

<?php
    include '../core/core.php';
?>
<!DOCTYPE html>
<html lang="en">

  <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Add Model</title>

    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <style>
      body {
        padding-top: 54px;
      }
      @media (min-width: 992px) {
        body {
          padding-top: 56px;
        }
      }
    </style>

  </head>

  <body>

    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
      <div class="container">
        <a class="navbar-brand" href="../">Leaked OnlyFans Girls</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item active">
              <a class="nav-link" href="http://leakedof.us">Home</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Add Girl</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

    <!-- Page Content -->
    <div class="container">
      <form method="POST" action="index.php">
      <div class="row">
          <div class="col-lg-12 text-center">
            <h3 class="mt-5">Copy the URL <font color="red">username</font> of the girl. Example: instagram.com/[<font color="red">xenia</font>]</h3>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">https://instagram.com/</span>
              </div>
              <input type="text" placeholder="xenia" name="instaProfLink" class="form-control" id="basic-url" aria-describedby="basic-addon3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">Girl Name</span>
              </div>
              <input type="text" placeholder="Full Name" name="girlName" class="form-control" id="basic-url" aria-describedby="basic-addon3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">Profile Pic</span>
              </div>
              <input type="text" placeholder="Profile Picture" name="profilepic" class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <p class="lead">Add the images from the girl profile <b>(NOT REQUIRED)</b></p>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">IMAGE</span>
              </div>
              <input type="text" name="pic1" placeholder="https://www.instagram.com/p/BedEtBog-DB/" class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">IMAGE</span>
              </div>
              <input type="text" name="pic2" placeholder="https://www.instagram.com/p/BedEtBog-DB/" class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">IMAGE</span>
              </div>
              <input type="text" name="pic3" placeholder="https://www.instagram.com/p/BedEtBog-DB/" class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">IMAGE</span>
              </div>
              <input type="text" name="pic4" placeholder="https://www.instagram.com/p/BedEtBog-DB/" class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">IMAGE</span>
              </div>
              <input type="text" name="pic5" placeholder="https://www.instagram.com/p/BedEtBog-DB/" class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon3">TAGS</span>
              </div>
              <input type="text" name="tags" placeholder="separate with , " class="form-control" id="basic-url" aria-describedby="basic-addon3">
            </div>
            <button type="submit" name="submitGirl" class="btn btn-outline-success btn-lg btn-block" >Submit</button>
            <?php

            if(isset($_POST["submitGirl"])) {
                $name = $_POST["girlName"];
                $url = $_POST["instaProfLink"];
                $profilepic = $_POST["profilepic"];
                $pic1 = $_POST["pic1"];
                $pic2 = $_POST["pic2"];
                $pic3 = $_POST["pic3"];
                $pic4 = $_POST["pic4"];
                $pic5 = $_POST["pic5"];
                $tags = $_POST["tags"];
                $timePosted = "";
                $havenude = 1;

                $sql = "INSERT INTO modelprofile VALUES (
                    '',
                    " . $conn->real_escape_string($name) . ",
                    " . $conn->real_escape_string($url) . ",
                    " . $conn->real_escape_string($profilepic) . ",
                    " . $conn->real_escape_string($pic1) . ",
                    " . $conn->real_escape_string($pic2) . ",
                    " . $conn->real_escape_string($pic3) . ",
                    " . $conn->real_escape_string($pic4) . ",
                    " . $conn->real_escape_string($pic5) . ",
                    " . $conn->real_escape_string($tags) . ",
                    " . $conn->real_escape_string($timePosted) . ",
                    " . $conn->real_escape_string($havenude) . "
                )";
                $result = $conn->query($sql);
                if($result === false) {
                    trigger_error("A required file did not exist!", E_USER_ERROR);
                    trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
                } else {
                    echo "model added";
                }
            } else {
                echo "doesnt exist";
            }
            ?>
            <br>
            <p class="lead">
              <b>HOW TO GET THE IMAGES?</b><br>
              <b>1.</b> Visit the girl Instagram profile<br>
              <b>2.</b> Click on the image you would like to share here<br>
              <b>3.</b> Copy the link of the image from the URL<br>
              <b>4.</b> Paste in the fields above
            </p>
            <p class="lead"><b>What if you leave empty the images?</b></p>
            <p class="lead">One member of our team will visit the girl profile and make sure to collect the best ones from it.</p>
            <p class="lead">So you dont have to worry does your girl will be shown in a good light + you dont have to spend time :)</p>
            <br><br><br><br><br><br><br><br>
          </div>

      </div>
      </form>
    </div>

    <!-- Bootstrap core JavaScript -->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  </body>

</html>
commented: Can you share the source for core.php? +1

Does anyone visited it yet? Or have a solution to this BIG problem

I have not visited the site, but I tested your code (without database interaction):

  1. Clicking submit does submit the form and the php code is processed.
  2. $timePosted is always empty.

Still, without knowing what core.php does, I can't say much else.

Here is the core file

Please visit the link and see in real time, i cannot figure out whats the problem
P.S there is no pictures or adult stuff on the website

<?php
$conn = mysqli_connect($DBServer, $DBUser, $DBPass, $DBName);

// Check connection
if ($conn->connect_error) {
  die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
}

  $sql = "CREATE TABLE modelprofile (
        ID INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        name TEXT(64) NOT NULL,
        url VARCHAR(128),
        profilepic VARCHAR(128),
        pic1 VARCHAR(2048),
        pic2 VARCHAR(2048),
        pic3 VARCHAR(2048),
        pic4 VARCHAR(2048),
        pic5 VARCHAR(2048),
        tags VARCHAR(1024),
        posttime TIMESTAMP(),
        have_nude INT(1))";
if($conn->query($sql)) {
  echo "Table admins created successfully";
}
?>

Alright!

P.S there is no pictures or adult stuff on the website

That is irrelevant. I'm just looking at the code ;-)

In core.php

Line 2:

$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);

Line 6:

die('Connect Error (' . $conn->connect_errno . ') ' . $conn->connect_error);

Line 20:

posttime TIMESTAMP,

In index.php

Line 128 (because your ID column is auto-increment):

$sql = "INSERT INTO modelprofile  (`name`, `url`, `profilepic`, `pic1`, `pic2`, `pic3`, `pic4`, `pic5`, `tags`, `posttime`, `have_nude`) VALUES (

Dani's suggestion to use $conn->real_escape_string() did not work for me, so I had to add the single quotes (') around them. They may work for you, but if you have errors turned on, MySQL will yell at you if they don't. In any event, I suggest you use prepared statements to prevent SQL injection attacks that, given the nature of your site, I am sure will be forthcoming.

Line 139:

NOW(),

This is because:

  1. the datafield is of type TIMESTAMP, and
  2. an empty string is not compatible with that field type. By using NOW() you write the current timestamp to your database.

Line 144:

trigger_error('A required file did not exist! Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);

Line 145:
Delete it because once you call trigger_error the first time, the second call is unreachable.

Bringing it all together now:

core.php

<?php
$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);

// Check connection
if ($conn->connect_error) {
  die('Connect Error (' . $conn->connect_errno . ') ' . $conn->connect_error);
}

  $sql = "CREATE TABLE IF NOT EXISTS `modelprofile` (
        `ID` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        `name` TEXT(64) NOT NULL,
        `url` VARCHAR(128),
        `profilepic` VARCHAR(128),
        `pic1` VARCHAR(2048),
        `pic2` VARCHAR(2048),
        `pic3` VARCHAR(2048),
        `pic4` VARCHAR(2048),
        `pic5` VARCHAR(2048),
        `tags` VARCHAR(1024),
        `posttime` TIMESTAMP,
        `have_nude` INT(1))";

if($conn->query($sql)) {
  echo "Table admins created successfully";
}

index.php

<?php
    include '../core/core.php';
?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Add Model</title>

    <!-- Bootstrap core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <style>
        body {
            padding-top: 54px;
        }

        @media (min-width: 992px) {
            body {
                padding-top: 56px;
            }
        }
    </style>

</head>

<body>

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
        <a class="navbar-brand" href="../">Leaked OnlyFans Girls</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive"
                aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="http://leakedof.us">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Add Girl</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<!-- Page Content -->
<div class="container">
    <form method="POST" action="index.php">
        <div class="row">
            <div class="col-lg-12 text-center">
                <h3 class="mt-5">Copy the URL <font color="red">username</font> of the girl. Example:
                    instagram.com/[<font color="red">xenia</font>]</h3>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">https://instagram.com/</span>
                    </div>
                    <input type="text" placeholder="xenia" name="instaProfLink" class="form-control" id="basic-url"
                           aria-describedby="basic-addon3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">Girl Name</span>
                    </div>
                    <input type="text" placeholder="Full Name" name="girlName" class="form-control" id="basic-url"
                           aria-describedby="basic-addon3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">Profile Pic</span>
                    </div>
                    <input type="text" placeholder="Profile Picture" name="profilepic" class="form-control"
                           id="basic-url" aria-describedby="basic-addon3">
                </div>
                <p class="lead">Add the images from the girl profile <b>(NOT REQUIRED)</b></p>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic1" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic2" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic3" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic4" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">IMAGE</span>
                    </div>
                    <input type="text" name="pic5" placeholder="https://www.instagram.com/p/BedEtBog-DB/"
                           class="form-control" id="basic-url" aria-describedby="basic-addon3">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="basic-addon3">TAGS</span>
                    </div>
                    <input type="text" name="tags" placeholder="separate with , " class="form-control" id="basic-url"
                           aria-describedby="basic-addon3">
                </div>
                <button type="submit" name="submitGirl" class="btn btn-outline-success btn-lg btn-block">Submit</button>
                <?php

                if (isset($_POST["submitGirl"])) {
                    $name       = $_POST["girlName"];
                    $url        = $_POST["instaProfLink"];
                    $profilepic = $_POST["profilepic"];
                    $pic1       = $_POST["pic1"];
                    $pic2       = $_POST["pic2"];
                    $pic3       = $_POST["pic3"];
                    $pic4       = $_POST["pic4"];
                    $pic5       = $_POST["pic5"];
                    $tags       = $_POST["tags"];
                    $havenude   = 1;

                    $sql = "INSERT INTO modelprofile  (
                        `name`,
                        `url`,
                        `profilepic`,
                        `pic1`,
                        `pic2`,
                        `pic3`,
                        `pic4`,
                        `pic5`,
                        `tags`,
                        `posttime`,
                        `have_nude`
                        )
                    VALUES (
                        '" . $conn->real_escape_string($name) . "',
                        '" . $conn->real_escape_string($url) . "',
                        '" . $conn->real_escape_string($profilepic) . "',
                        '" . $conn->real_escape_string($pic1) . "',
                        '" . $conn->real_escape_string($pic2) . "',
                        '" . $conn->real_escape_string($pic3) . "',
                        '" . $conn->real_escape_string($pic4) . "',
                        '" . $conn->real_escape_string($pic5) . "',
                        '" . $conn->real_escape_string($tags) . "',
                        NOW()," // posttime
                        ."'" . $conn->real_escape_string($havenude) . "')";
                    $result = $conn->query($sql);
                    if ($result === false) {
                        trigger_error('A required file did not exist! Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
                    } else {
                        echo "model added";
                    }
                } else {
                    echo "doesnt exist";
                }
                ?>
                <br>
                <p class="lead">
                    <b>HOW TO GET THE IMAGES?</b><br>
                    <b>1.</b> Visit the girl Instagram profile<br>
                    <b>2.</b> Click on the image you would like to share here<br>
                    <b>3.</b> Copy the link of the image from the URL<br>
                    <b>4.</b> Paste in the fields above
                </p>
                <p class="lead"><b>What if you leave empty the images?</b></p>
                <p class="lead">One member of our team will visit the girl profile and make sure to collect the best
                    ones from it.</p>
                <p class="lead">So you dont have to worry does your girl will be shown in a good light + you dont have
                    to spend time :)</p>
                <br><br><br><br><br><br><br><br>
            </div>

        </div>
    </form>
</div>

<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>

</html>

I tested this locally and it worked for me, so it should work you. If it doesn't, make sure you have error reporting on in your PHP to see what exactly is not working.

Good luck!

I have updated it in my code and now only shows the echo "Table admins created successfully"

But doesn't update the database table when i add some text in the fields and press Submit button

Table admins created successfuly will only show up the first time you run your script because the table did not exist before in your database. I believe it was because your CREATE statement had an error in it (posttime = TIMESTAMP()). Now, error-free, your table now exists.

As to why it is not saving the for data, I cannot say. I tested it locally and it worked. I can only do so much with the code you shared, and I'm glad you found my suggestions helpful (right?). If your database is not updating, you might be getting errors, but you are unable to see them because you have error reporting turned off.

Try adding the following at the beginning of core.php and see what happens when you submit the form:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

There are no errors shown after i added the code in the core.php

BTW as you can see, at the bottom of the button it says " doesnt exist " without button is pressed, when you visit the website.

**

EDIT: It works now, thank you @gce517 !

**

The problem was the sql query i got earlier?

But i have weird database INPUT tho. Look at the Primary ID in the table. why does it started to count column 50 from the 46 column and on ....

Here is a picture

https://prnt.sc/I6SUmbWlOeAE

-- Edit:

EDIT: It works now, thank you @gce517 !

Awesome!!

--

BTW as you can see, at the bottom of the button it says " doesnt exist " without button is pressed, when you visit the website.

Yes, and that is expected on the first run of your script.

Why?

Well, you have an if-then statement in index.php that checks to see whether or not $_POST(['submitGirl']) is set:

if (isset($_POST["submitGirl"])) {
    // assign $_POST values to individual variables
    // create the insert query
    // run the query
    // check if the query executed successfully
} else { // $_POST["submitGirl"]) is NOT set
    echo "doesnt exist";
}

So, the very first time you run the script, it will create the modelprofile table. The table is now ready to accept submissions.

Every time after the first run that you browse to that page, it will check if $_POST(['submitGirl']) is set. If it is, it means that you clicked the submit button. If it is not, you will see doesnt exist.

But i have weird database INPUT tho. Look at the Primary ID in the table. why does it started to count column 50 from the 46 column and on ....

My guess is that you may have 'hardcoded' the ID numbers when inserting some records and, when removing the ID from the insert statement, it began to auto-increment from the last one inserted. Or you may have simply sorted the output by a field other than ID.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.