I'm uploading a audio-file (au).
The Database has a id int auto_increment
word varchar(255)
The ID should give the audio an id with link to the word.
I'm making a dictation..
Expand|Select|Wrap|Line Numbers
- <?
- require("database.inc.php");
- connectDatabase();
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Vælg lyd til <?=$_POST['title']?></title>
- <link href="style.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <? if(file_exists("text/".$_POST['title'].".txt")) {
- ?>
- <h1>choose sound</h1>
- <h3 style="color:#CC3333">Pas på! there are allready a dictation with that word.<br />
- Hvis du er ved at lave et nyt diktat, burde du gå <a href="javascript:history.back()">tilbage</a> og vælge en anden titel.
- Gør du ikke det, bliver diktatet med titelen "<?=$_POST['title']?>" erstattet med dette diktat her!</h3>
- <?
- }
- ?>
- <form enctype="multipart/form-data" action="save_dict.php" method="post">
- <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
- <table border="0">
- <?
- $result=mysql_query("SELECT word FROM repository;");
- while($entry=mysql_fetch_array($result)) {
- $repository[]=$entry[0];
- }
- $word_start=0;
- $word_stop=0;
- $open=false;
- $words=array();
- $content=$_POST['content'];
- for($i=0;$i<strlen($content);$i++) {
- if(substr($content,$i,1)=="<" && !$open) {
- $word_start=$i+1;
- $open=true;
- }
- elseif(substr($content,$i,1)==">" && $open) {
- $word_stop=$i;
- $word=substr($content,$word_start,$word_stop-$word_start);
- if(!in_array($word,$repository)) {
- $words[]=$word;
- ?>
- <tr>
- <td><?=$word?></td>
- <td><input type="file" name="<?=$word?>" /></td>
- </tr>
- <?
- }
- $open=false;
- }
- }
- ?>
- </table>
- <input type="hidden" name="words" value="<? echo implode(";",$words); ?>" />
- <input type="hidden" name="content" value="<?=$_POST['content']?>" />
- <input type="hidden" name="title" value="<?=$_POST['title']?>" />
- <input type="submit" value="Upload & gem" />
- </form>
- </body>
- </html>