PlagueInfected Posted August 6, 2009 Share Posted August 6, 2009 I'm trying to make an admin panel and the thing I want to do is my admins to post updates to be displayed onto the site. I made the form for it as well as the script here is the full code. <fieldset> <legend>Updates</legend> <form action="update_page.php" method="post"> Administrator Name: <input type="text" name="name" /> Subject: <input type="text" name="subject" /> Text: <input type="text" name="mainsubject" /> <input type="submit" value="submit" /> <input type="reset" value="reset" /> </form> </fieldset> here is the php script <?php //update_page.php /* $name = $_POST['name']; $subject = $_POST['subject']; $mainsubject = $_POST['mainsubject']; */ //using variables to attempt an array $myFile = "inc/updates.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<div class=\"name\">" . $_POST['name'] . "</div>"; fwrite($fh, $stringData); $stringData = "<div class=\"subject\">" . $_POST['subject'] . "</div>"; fwrite($fh, $stringData); $stringData = "<div class=\"mainsubject\">" . $_POST['mainsubject'] . "</div>"; fclose($fh); ?> Link to comment https://forums.phpfreaks.com/topic/169098-post-and-write-onto-a-page/ Share on other sites More sharing options...
Adam Posted August 6, 2009 Share Posted August 6, 2009 ...And your question / problem is? Link to comment https://forums.phpfreaks.com/topic/169098-post-and-write-onto-a-page/#findComment-892169 Share on other sites More sharing options...
PlagueInfected Posted August 6, 2009 Author Share Posted August 6, 2009 i dont know how to call it, i dont know how to make the statement to write it Link to comment https://forums.phpfreaks.com/topic/169098-post-and-write-onto-a-page/#findComment-892188 Share on other sites More sharing options...
darkfreaks Posted August 6, 2009 Share Posted August 6, 2009 plague i believe you would want to use fread Link to comment https://forums.phpfreaks.com/topic/169098-post-and-write-onto-a-page/#findComment-892215 Share on other sites More sharing options...
PlagueInfected Posted August 6, 2009 Author Share Posted August 6, 2009 why fread? I need the post to be written onto the page Link to comment https://forums.phpfreaks.com/topic/169098-post-and-write-onto-a-page/#findComment-892230 Share on other sites More sharing options...
darkfreaks Posted August 6, 2009 Share Posted August 6, 2009 try: <?php //update_page.php $name = $_POST['name']; $subject = $_POST['subject']; $mainsubject = $_POST['mainsubject']; //using variables to attempt an array $myFile = "inc/updates.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "<div class=\"name\">" . $_POST['name'] . "</div>"; fwrite($fh, $stringData); $stringData = "<div class=\"subject\">" . $_POST['subject'] . "</div>"; fwrite($fh, $stringData); $stringData = "<div class=\"mainsubject\">" . $_POST['mainsubject'] . "</div>"; //checking if data is written to file if true ech success if (fwrite($fh, $stringData) === FALSE) { echo "Cannot write to file ($myFile)"; exit; } echo "Success, wrote ($stringData) to file ($myFile)"; fclose($fh); ?> Link to comment https://forums.phpfreaks.com/topic/169098-post-and-write-onto-a-page/#findComment-892239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.