php - nothing is displayed due to a php error -
i started learning php , following tutorial until encountered error.
with php way page displays nothing though worked in tutorial video.
i found many questions similar mine couldn't apply code.
anyway, i'm gonna cut chase
that's code
if ( !isset( $_post['fix_submit'] ) ) { $clickbait = strtolower $_post["clickbait_headline"]; // grab value textarea in $_post collection // make letters lowercase using strtolower() function // store in variable $fake = array( "doctors", "scientists", "shocked me", "won't believe", "will never believe", "hate" ); $replacefake = array( "so-called doctors", "so-called scientists", "was others", "will find normal", "won't surprised", "aren't threatened by" ); $honestheadline = str_replace ($fake, $replacefake, $clickbait ); }
the whole error first line because whenever remove page displays html php won't work.
edit
after fixing syntax error fixed part nothing being displayed help.
now says
undefined index: clickbait_headline on line 8
and when click submit button nothing happens anyway, that's whole code
<?php define ("title", "honest click bait headline"); if ( !isset( $_post['fix_submit'] ) ) { $clickbait = strtolower ($_post["clickbait_headline"]); // grab value textarea in $_post collection // make letters lowercase using strtolower() function // store in variable $fake = array( "doctors", "scientists", "shocked me", "won't believe", "will never believe", "hate", "hack", "simple" ); $replacefake = array( "so-called doctors", "so-called scientists", "was others", "will find normal", "won't surprised", "aren't threatened by", "common knowledge", "well-known" ); $honestheadline = str_replace ($fake, $replacefake, $clickbait ); } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php echo title; ?></title> <!--bootstrap css--> <link href="bootstrap/css/bootstrap.css" rel="stylesheet"> <!-- custom styles --> <link href="styles.css" rel="stylesheet"> </head> <body> <div class="container"> <h1><?php echo title; ?></h1> <p class="lead">hate click baits? turn annoying headlines realistic , honest ones.</p> <div class="row"> <form class="col-sm-7 col-sm-offset-2" action="" method="post"> <textarea class="form-control input-lg" name="clickbait_headline" rows="2" placeholder="paste clickbait headline here"></textarea><br> <button class="btn btn-primary btn-lg pull-right" type="submit" name="fix_submit">make honest!</button> </form> </div> <?php if (!isset( $_post["fix_submit"])) { echo "<strong class='text-danger'>original headline</strong> <h4>".ucwords($clickbait)."</h4><hr><br> "; // ucwords() uppercase first letter in every word echo "<strong class='text-success'>honest headline</strong> <h4>".ucwords($honestheadline)."</h4>"; } ?> </div> </body> </html>
replace $clickbait = strtolower $_post["clickbait_headline"];
with
$clickbait = strtolower($_post["clickbait_headline"]);
Comments
Post a Comment