Getintothegame Posted March 13, 2007 Share Posted March 13, 2007 Okay, please bear with me. I've been a fan of HTML for ages now and really am going to try to be working on expanding my PHP knowledge in the next few months. I've been working with a few books and online services and have the general grasp of it, however, my ways of scripting are very inefficient. I was wondering if someone would help clean this small script up and explain why they changed what they did? I'd very much appreciate it. <form name="input" method="post" action="<?php echo $_SERVER['SCRIPT_NAME']?>"> <title>Getintothegame.net News Post</title> <?php echo 'Now: '. date('m/d/Y') ."\n"; ?><br><br> <label for="firstname">Title: </label> <input type="text" name="name" id="firstname" /><br> <br> Story:<br> <textarea name="story" id="longstory" cols=70 rows=18/></textarea> </p> <p><input type="submit" name="submit" value="submit" /></p> </form> <?php if (isset($_POST['submit'])) { $date = date('m/d/Y'); $name = $_POST['name']; $story2 = $_POST['story']; $story3 =nl2br($story2); $story = ereg_replace("\n", " ", $story3); $path = "../news.txt"; $handle = fopen($path, 'r'); $oldcontent = fread($handle, filesize($path)); $handle = fopen($path, 'w+'); $content = $date .": " . $name . "¶" . $story . "\r\n" . $oldcontent; //echo $content; if(!fwrite($handle, $content)) { echo "File write failed."; } else { echo "Success!"; } fclose($handle); } ?> Thank you again! Link to comment https://forums.phpfreaks.com/topic/42464-general-script-cleanup-requested-help/ Share on other sites More sharing options...
monk.e.boy Posted March 13, 2007 Share Posted March 13, 2007 I'd use a database to store my data. But other than that it looks good. :) monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42464-general-script-cleanup-requested-help/#findComment-206087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.