Page 3 of 3

Posted: Tue Aug 22, 2006 12:49 am
by daedalus__
I want to see the entire script.

code

Posted: Tue Aug 22, 2006 12:13 pm
by akimm
program form:

Code: Select all

<form action="journalbox.php" method="POST">
<p><b>Date</b>
<input type="text" value="<?php echo date("F j, Y, g:i a");?>" name="date" size="30"></p>

<p><b>Mood</b>
<select name="mood">
<option value="apathetic">apathetic
<option value="overjoyed">overjoyed
<option value="inquisitive">inquisitive
<option value="outlandish">outlandish
<option value="appreciative">appreciative
<option value="confused">confused
<option value="displeased">displeased
<option value="disgruntled">disgruntled
<option value="sick">sick
<option value="terrified">terrified
<option value="mental">mental
<option value="eruditic">eruditic
<option value="forlorn">forlorn
<option value="convuluted">convuluted
<option value="ingenious">ingenious
<option value="arrogant">arrogant
<option value="free">free
<option value="stupid">stupid
<option value="moronic">moronic
<option value="pointless">pointless
</select>

<?php
$smile = array('2guns', 'somethingElse');

/**
 * This generates a drop down with
 * the array index as the key and
 * the smilie name as the value in the form
 **/
echo '<select name="smile">';
foreach ($smile as $key => $value)
{
    echo '<option value="' . $key . '">' . $value . '</option>';
}
?>

<select name="smile">

<?php
$img_id = $_POST['smile'];
echo '<img src="/journal06/smile/' . $smile[$img_id] . '.gif" />';
?>
</select>

<p><b>entry</b>
<TEXTAREA NAME="entry" COLS="80" ROWS="5" WRAP="virtual"></TEXTAREA></P>

<p><input type="submit" name="submit" value="send your entry!"></p>
</form>
journalbox.php

Code: Select all

<?php
$filename = "journalaug_sept.txt";
$handle = fopen($filename, 'a');
$write_string = $_POST['date'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= $_POST['mood'] . $_POST['smile'] . $smile[$img_id] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= $_POST['entry'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= "<HR NOSHADE SIZE=4 COLOR=BLUE>";

fwrite($handle, $write_string);
	fclose($handle);
?>
journal.php

Code: Select all

<?php
include('journalread.php')
?>
journalread.php

Code: Select all

<?php
$myFile = "journalaug_sept.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
?>

Re: code

Posted: Tue Aug 22, 2006 10:41 pm
by RobertGonzalez
Try this...
program form:

Code: Select all

<form action="journalbox.php" method="POST">
<p><b>Date</b>
<input type="text" value="<?php echo date('F j, Y, g:i a');?>" name="date" size="30"></p>

<p><b>Mood</b>
<select name="mood">
<option value="apathetic">apathetic
<option value="overjoyed">overjoyed
<option value="inquisitive">inquisitive
<option value="outlandish">outlandish
<option value="appreciative">appreciative
<option value="confused">confused
<option value="displeased">displeased
<option value="disgruntled">disgruntled
<option value="sick">sick
<option value="terrified">terrified
<option value="mental">mental
<option value="eruditic">eruditic
<option value="forlorn">forlorn
<option value="convuluted">convuluted
<option value="ingenious">ingenious
<option value="arrogant">arrogant
<option value="free">free
<option value="stupid">stupid
<option value="moronic">moronic
<option value="pointless">pointless
</select>
<br /><br />
<select name="smile">
<?php
$smile = array('2guns', 'somethingElse');

/**
 * This generates a drop down with
 * the array index as the key and
 * the smilie name as the value in the form
 **/
foreach ($smile as $key => $value)
{
    echo '<option value="' . $key . '">' . $value . '</option>';
}
?>
</select>

<p><b>entry</b>
<TEXTAREA NAME="entry" COLS="80" ROWS="5" WRAP="virtual"></TEXTAREA></P>

<p><input type="submit" name="submit" value="send your entry!"></p>
</form>
journalbox.php

Code: Select all

<?php
$smile = array('2guns', 'somethingElse');

$img_id = $_POST['smile'];
echo '<img src="/journal06/smile/' . $smile[$img_id] . '.gif" />';

$filename = "journalaug_sept.txt";
$handle = fopen($filename, 'a');
$write_string = $_POST['date'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= $_POST['mood'] . $_POST['smile'] . $smile[$img_id] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= $_POST['entry'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= "<HR NOSHADE SIZE=4 COLOR=BLUE>";

fwrite($handle, $write_string);
	fclose($handle);
?>
journal.php

Code: Select all

<?php
include('journalread.php')
?>
journalread.php

Code: Select all

<?php
$myFile = "journalaug_sept.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
?>

Everah

Posted: Tue Aug 22, 2006 11:10 pm
by akimm
That code is still not the right solution, i even checked the textfile to see if it had been written, but no luck.

ok

Posted: Sat Aug 26, 2006 6:35 pm
by akimm
So is there no way to actually do this by means of flatfile? Will I need to incoperate some MYSQL DB's or another DB to make this possible?