Skip to content

CodeCorner2

leithoff edited this page Jul 5, 2016 · 7 revisions

Wiki ▸ [Developer Docs](Developer Docs) ▸ [Code Corner](Code Corner) ▸ day twoday three


On day two of our training session we stepped into how we should send and recieve data, and how we should design our application a bit more the eGroupware way.

Lets start with the traditional way to climb the hill We decided that we wanted to have some input possibilities to affect the output of our greeting of the world. Our index.php file now includes a form to start with and a form that comes into action to display the users input and a button to reload the whole thing.

<?php
/*
 prepare some application information for eGroupware to know
 If the applicationname of your application (e.g.: test) and the value of
 currentapp does not match, you will recieve an authentication error
*/

$GLOBALS['egw_info'] = array('flags' => array(
    'currentapp'=>  'test' ,
    'noheader'  =>  False,
    'nonavbar'  =>  False,
));
/*
 include THE eGroupware header, that takes care of the sessionhandling
 and the other background stuff
 the information provided above is used/required here in order to get the application running
*/
include('../header.inc.php');

if (trim($_POST['fname'].$_POST['sname'])!='')
{
            echo "<br>Hello ".$_POST['fname']." ".$_POST['sname']."<br>";
            echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
            <input type='submit' value=' Reload '>
            </form>";
} else {
            echo "Type a name to be greeted accordingly <br>";
            echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>
              <p>first name:<br><input name='fname' type='text' size='30' maxlength='30'></p>
              <p>name:<br><input name='sname' type='text' size='30' maxlength='40'></p>
                    <input type='submit' value=' Submit '>
                    <input type='reset' value=' Cancel'>
            </form>";
}
//display the eGroupware footer
common::egw_footer();
Clone this wiki locally