0

im trying to create a form which allows to auto create posts but i can't to write in database.

Here's my code in form.php:


include('con_db.php');

if (isset($_POST['submit'])){
    if (strlen($_POST['mentador']) > 1 && strlen($_POST['mentado']) > 1 && strlen($_POST['mentada']) > 1 && strlen($_POST['titulomentada']) > 1) {
        $mentador = trim($_POST['mentador']);
        $mentado = trim($_POST['mentado']);
        $mentada = trim($_POST['mentada']);
        $titulomentada = trim($_POST['titulomentada']);
        $consulta = "INSERT INTO wp_posts(post_author, post_status, comment_status, ping_status, post_name, post_parent, post_type) VALUES ('1', 'publish', 'open', 'open', '$titulomentada', '0', 'mentadas')";
        $resultado = mysqli_query($conex,$consulta);
        if ($resultado){
            ?>
            <h3>¡A huevo!</h3>
            <?php
        } else{
            ?>
            <p>Ni pedo</p>
            <?php
        }
    } else{
        ?>
        <h1><span class="line-throug">LLENA LOS DATOS</span></h1>
        <?php
    }
}

I could connect to the database, i've already echo a "connection successful", that's not the problem.

By the way the connection php:

<?php

    $conex = mysqli_connect ('localhost', 'root', 'root', 'podcast');

?>

Thank you very much!!!!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy