Jump to content

Problems with glob()


akimm

Recommended Posts

I'm using glob to bring about all the smileys in my one directory into a select menu.  It does this fine, I select my smile i chose to use, then submit the form, during the writing however, instead of chosing the name of the smile hypothetically smile1.gif, it numerically lables the smiles like an array.  My problem is I need to use the exact name for the smile and I need to also attach <img src="$_POST[''smile]"> into my php file that does the writing process.  I will post my code thus far, anyone who can help is greatly appreciated.


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

></b>" 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">

This is the form
[code=php:0]
<?php

$files = glob("smile/*.gif");
##Display $files 
foreach ($files 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>
[/code]

this is the file that writes to my directory
[code=php:0]
<?php
$filename = "journalaug_sept.txt";
$handle = fopen($filename, 'a');
$write_string = $_POST['date'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= $_POST['mood'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= $_POST['smile'] . "<br>";
$write_string .= $_POST['entry'] . "<font family=arial>" . "<BR>" . "<BR>";
$write_string .= "<HR NOSHADE SIZE=4 COLOR=BLUE>";

fwrite($handle, $write_string);
fclose($handle);
?>
<h1>Sucessfully posted</h1>

<br><br>
<?php
echo $_POST['date'] . "<br>";
echo $_POST['mood'] . "<br>";
echo $_POST['smile'] . $_POST['value'] . "<br>";
echo $_POST['entry'] . "<br>";
?>

<br><br>
<a href="http://www.akimm.com/journal06/journal.php">Go To Journal Sean!</a>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/20062-problems-with-glob/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.