简体   繁体   中英

Transform HTML text into input field

Consider a standard web page created with PHP passing some text variables, taken from a database, to an HTML file.

I would like to be able to modify the value of the variables using as an interface the real HTML file (so one can actually see where the variables are in the page).

I tried simply using a substitution like " $variable --> < input value="'.$variable.'"/> ". This works only in some cases. For example it doesn't work if the variable is the content on an <a> tag or if the variable contains some HTML.

Do you have any suggestion on how I could accomplish this? Is there a way to force <input> tags anywhere in my HTML file, so that they can be seen from the end user?

This is the default and the easiest way to edit your variables (content of your site)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Edit</title>
</head>
<body>

<?php
    $title = "Lorem Ipsum";
    $content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry <strong>Lorem Ipsum</strong> has been the industry's <a href=\"http://justin-bieber.com\">standard dummy</a> text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
<pre>function toggle(o) {
    var e = document.getElementById(o);
    e.style.display = (e.style.display != 'none' ? 'none' : '' );
}</pre>";
    $author = "Anonymous";
?>

    <form enctype="multipart/form-data" method="post" action="_URL_">
        <label>Tilte</label><br /><input type="text" name="title" value="<?php echo  stripslashes($title) ?>" /><br />
        <label>Content</label><br /><textarea name="content"><?php echo stripslashes($content) ?></textarea><br />
        <label>Author</label><br /><input type="text" name="author" value="<?php echo  stripslashes($author) ?>" /><br />
        <input type="submit" name="submit" value="submit" />
    </form>

</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM