Tuesday, October 11, 2022
HomeWordPress Developmentcapabilities - Various to php echo inside code

capabilities – Various to php echo inside code


I’m writing throughout the capabilities.php file, and am making an attempt to show HTML code, together with back-end php code. My drawback is utilizing the echo assertion. It’s fairly troublesome to make use of the echo perform, as by placing issues in ‘ ‘ removes colour coding. It additionally makes it tougher to work with databases. I’m able to show my code, however not one of the php code appears to work. If I click on on the submit button, nothing occurs, no error. It is as whether it is fundamental HTML. Is there any various to echo? If not, how does one work with php back-end code with echo?

EDIT: The whole lot proven under till the ending tag is encapsulated by ‘ ‘ on account of echo

My first traces:

perform add_content2() {
    echo '

<!-- PHP CODE -->
<?php

$error = "";

// CONNECTS TO DATABASE
$dbtype = mysqli_connect("localhost", "JohnLyons", "2012Zombies123!", "b1s243006078611");

if(!$dbtype) {
die(mysqli_error($dbtype));
}

// WHAT HAPPENS ON SUBMIT
if(isset($_POST["submit"])) {
    $identify = $_POST["name"];
    if(empty($identify)) {
        wc_add_notice(("Fill in the complete discipline"), "error");
    } else {
    // Queries database. Find out how to get header to remain on web page
        mysqli_query($dbtype, "INSERT INTO todo(identify) VALUES ("$identify")");
        $referer = $_SERVER["HTTP_REFERER"]; 
        header("location: $referer");
    }
}

$name_loop = mysqli_query($db, "SELECT * FROM todo");

?>

The desk itsef:

<tbody>
        <!-- LOOPS THROUGH ARRAY -->
            <?php whereas ($row = mysqli_fetch_array($name_loop)) { ?>

            <tr>
                <td> <?php echo $row["name"]; ?> </td>
            </tr>
            
            <?php } ?>
            
        </tbody>

Lastly, the submit button:

<type model="padding-top: 30px" methodology= "<?php echo $_SERVER["PHP_SELF"]; ?>" >
        <?php if (isset($error)) { ?>
            <p><?php echo $error; ?></p>
        <?php } ?>
        <enter kind="textual content" placeholder="Enter pupil data" identify="job">
        <button kind="submit" identify="submit" model="margin-top: 10px">Register Pupil</button>
    </type>

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments