php - Switching external functions with form buttons and if statements -


i've been searching answer day. i've got 3 functions have forms in them. i'm trying call forms index page using form. what's happening can call functions , have them display when click appropriate button when try submit forms in functions index page function forms disappear , nothing gets posted. i'm not sure if i'm trying possible thought i'd ask.

index.php if (isset($_post['posts'])) {     posts(); } if (isset($_post['styles'])) {     styles();    } if (isset($_post['templates'])) {     templates(); }  echo php_eol."\t\t".'<span class="switch">'.php_eol; echo "\t\t\t".'<form class="mode" method="post" action="'.htmlentities($_server['php_self']).'">'.php_eol; echo "\t\t\t\t".'<button class="edit" name="posts" type="submit" value="posts">posts</button>'.php_eol; echo "\t\t\t\t".'<button class="edit" name="styles" type="submit" value="styles">styles</button>'.php_eol; echo "\t\t\t\t".'<button class="edit" name="templates" type="submit" value="templates">templates</button>'.php_eol; echo "\t\t\t".'</form>'.php_eol; echo "\t\t".'</span>'; 

and..

posts.php if (isset($_post['fileselect'])) {     $fileselect = $_post['fileselect'];     $firstline = trim(fgets(fopen($fileselect, 'r')));     $firstline = strip_tags($firstline);     $strip = substr($firstline, 0, 110);     echo php_eol."\t\t".'<article class="edit">'.php_eol;     echo "\t\t\t".'<form class="edit" method="post" action="'.htmlentities($_server['php_self']).'">'.php_eol;     echo "\t\t\t\t".'<span class="filename">filename: '.basename($fileselect).'</span>'.php_eol;     echo "\t\t\t\t".'<span class="post">'.$strip.'</span>'.php_eol;     // don't change, readfile picky.     echo "\t\t\t\t".'<textarea class="editor" id="code" name="content">';     readfile($fileselect);     echo '</textarea>'.php_eol;     // don't change, readfile picky.     echo "\t\t\t\t".'<span class="edit">'.php_eol;     echo "\t\t\t\t\t".'<button class="save" name="save" type="submit" value="'.$fileselect.'">save</button>'.php_eol;     echo "\t\t\t\t\t".'<button class="cancel" name="cancel" type="cancel">cancel</button>'.php_eol;     echo "\t\t\t\t".'</span>'.php_eol;     echo "\t\t\t".'</form>'.php_eol;     echo "\t\t".'</article>'.php_eol; };  echo php_eol."\t\t".'<aside class="delete">'.php_eol; echo "\t\t\t".'<form class="choose" method="post" action="'.htmlentities($_server['php_self']).'">'.php_eol; echo "\t\t\t\t".'<button class="new" name="newfile" type="submit">create new</button>'.php_eol; echo "\t\t\t\t".'<ul id="archives">'.php_eol; $filenames = glob('../posts/*.post'); rsort($filenames); foreach ($filenames $filename) {     $firstline = trim(fgets(fopen($filename, 'r')));     $firstline = strip_tags($firstline);     $entry = preg_replace('^../posts/^', 'filename: ', $filename);     echo "\t\t\t\t\t".'<p class="entry">'.$entry.'</p>'.php_eol;     echo "\t\t\t\t\t".'<li>'.php_eol;     echo "\t\t\t\t\t\t".'<span class="title">'.$firstline.'</span>'.php_eol;     echo "\t\t\t\t\t\t".'<button class="edit" name="fileselect" type="submit" value="'.$filename.'">edit</button>'.php_eol;     echo "\t\t\t\t\t\t".'<button class="delete" name="filedelete" type="submit" value="'.$filename.'">delete</button>'.php_eol;     echo "\t\t\t\t\t".'</li>'.php_eol; }; echo "\t\t\t\t".'</ul>'.php_eol; echo "\t\t\t".'</form>'.php_eol; echo "\t\t".'</aside>'.php_eol; 

i'm updating avoid bit of confusion. i'm doing works 1 function if call no conditional stuff: posts();

the posts function shows when index.php loaded , edit, delete, , new work dandy. if use form call it, shows doesn't work did before.

the odd thing far i'm aware, should working it's getting posted index.php.

the clicked posts button showing form submitted , correct response given.

</header> <aside class="delete">     <form class="choose" method="post" action="/nibble/admin/admin.php">         <button class="new" name="newfile" type="submit">create new</button>         <ul id="archives">             <p class="entry">filename: 2015-03-20-02:28:38.post</p>             <li>                 <span class="title">php breadcrumb</span>                 <button class="edit" name="fileselect" type="submit" value="../posts/2015-03-20-02:28:38.post">edit</button>                 <button class="delete" name="filedelete" type="submit" value="../posts/2015-03-20-02:28:38.post">delete</button>             </li> ...snip...         </ul>     </form> </aside> <span class="where">editing templates.</span> <span class="switch">     <form class="mode" method="post" action="/nibble/admin/admin.php">         <button class="edit" name="posts" type="submit" value="posts">posts</button>         <button class="edit" name="styles" type="submit" value="styles">styles</button>         <button class="edit" name="templates" type="submit" value="templates">templates</button>     </form> </span> <footer> 

now after having clicked edit button in posts function.

</header> <span class="switch">     <form class="mode" method="post" action="/nibble/admin/admin.php">         <button class="edit" name="posts" type="submit" value="posts">posts</button>         <button class="edit" name="styles" type="submit" value="styles">styles</button>         <button class="edit" name="templates" type="submit" value="templates">templates</button>     </form> </span> <footer> 

poof! gone!

this seemed rather unworkable problem i'm refactoring code use 1 function file display , operations. following isn't quite complete , i'm sure it's not pretty solved major issue of displaying different file types based on button click file type. i'm posting in case might of use someone.

$buttons = <<< nav          <span class="switch">             <form class="mode" name="switch" method="post" action="{$_server['php_self']}">                 <button class="edit" name="posts" type="submit" value="0">posts</button>                 <button class="edit" name="styles" type="submit" value="1">styles</button>                 <button class="edit" name="templates" type="submit" value="2">templates</button>                 <button class="edit" name="php" type="submit" value="php">php</button>             </form>         </span> nav;     echo $buttons;     $filenames = null;     if (isset($_post['posts'])) {         $filenames = glob('../posts/*.post');         rsort($filenames);     }     elseif (isset($_post['styles'])) {         $filenames = glob('../css/*.css');         sort($filenames);     }     elseif (isset($_post['templates'])) {         $filenames = glob('../gui/*.gui');         sort($filenames);     }     elseif (isset($_post['php'])) {         $filenames = glob('../*.php');         sort($filenames);     }     $liststart = <<< list          <aside class="delete">             <form class="choose" method="post" action="{$_server['php_self']}">                 <button class="new" name="newfile" type="submit">create new</button>                 <ul id="archives"> list;     echo $liststart;     foreach ((array) $filenames $filename) {         $firstline = trim(fgets(fopen($filename, 'r')));         $firstline = strip_tags($firstline);         $entry = preg_replace('^../posts/^', 'filename: ', $filename);         $listmid = <<< list                     <p class="entry">{$entry}</p>                     <li>                         <span class="title">{$firstline}</span>                         <button class="edit" name="fileselect" type="submit" value="{$filename}">edit</button>                         <button class="delete" name="filedelete" type="submit" value="{$filename}">delete</button>                     </li> list;         echo $listmid;     };     $listend = <<< list                 </ul>             </form>         </aside> list;     echo $listend; 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -