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
Share on other sites

You are passing the array key that holds the filename, not the actual filename. It doesn't actually look like you need the key, so try this:
[code]<?php
foreach(glob("smile/*.gif") as $f) echo "<option value='$f'>$f</option>";
?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.