mardi 27 novembre 2018

PHP - I can't save content from input

I am struggling with the problem on my website. I should create an form to fill which will display new information/news. I have code like this:

    <?php
include "0begin.php";

$title=$_POST["title"];
isset($title) or $title=$_GET["title"];
$msg=$_POST["msg"];
isset($msg) or $msg=$_GET["msg"];

?>
<h1>News</h1>

<form method="POST">
Title<br><input type=text input name="title" value=<?=$title?> ><br>
News<br>
<textarea input name="msg" cols=40 rows=5> </textarea><br>
<input type="submit">
<br><br>
</form>
<?php
$dateposted=date("YmdHis");
if (!empty($title) and !empty($msg)) {
    $fp=fopen("/home/aqueen/public_html/news/".$dateposted."txt", "w");
    fwrite($fp,$title,$msg);
    fwirte($fp,$msg);
    fclose($fp);    
    include "/home/aqueen/public_html/news/".$dateposted."txt"; }

?> 

My questions: 1) How can I fix that code? It generates new file but without content inside. 2) It doesn't show the new file on the website /probably doesn't include it properly/ 3) When it starts working- how I can let someone delete news from website without opening the code? /online/

Thank you in advance :)




Aucun commentaire:

Enregistrer un commentaire