Alright, I'm writing a quote submission script. Actually, I'm finished with that part.
http://minime001.net/temp/quotes.php
it writes to: http://minime001.net/temp/quotes.txt
What I want to do now is to read a random quote from the text file. How could I search for the (%%🙂 part and read what's after it? I mean I figure I'll use the fread() function, but I just don't see how. ;
Here's the code for the submission page, though:
<?php
$quote = (isset($_REQUEST['quote'])) ? $_REQUEST['quote'] : "";
$submit = (isset($_REQUEST['submit'])) ? $_REQUEST['submit'] : "";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Emerald Sword Quote System</title>
</head>
<body bgcolor="#b0b0b0">
<h1>Emerald Sword Quote System</h1>
<hr />
<?php if ($submit == Preview) { print('<pre><p>' . $quote . '</p></pre><hr />'); }
else if ($submit == Submit) {
print ('<h3>Your quote has been submitted:</h3>
<pre><p>' . $quote . '</p></pre>');
$fp = fopen( "quotes.txt", "a");
fwrite($fp, "\n(%%:)\n" . $quote);
fclose($fp);
}
if ($submit != Submit) { ?>
<form>
<p><textarea rows="15" cols="100" name="quote"><?php print( $quote ); ?></textarea></p>
<p><input type="submit" name="submit" value="Preview" /> <input type="submit" name="submit" value="Submit" /></p>
</form>
<?php } ?>
<hr />
<?php if ($submit == Submit) {
print('<form><p><input type="button" value="Submit Another Quote" onclick="location=\'?\'" /></p></form>'); } ?>
</body>
</html>