issues with adding a function

Discussion forum for MOD Writers regarding MOD Development.
Locked
gnarlita
Registered User
Posts: 4
Joined: Fri Jan 16, 2009 6:26 am

issues with adding a function

Post by gnarlita »

Code: Select all

function process_confirm(&$form)
        {
			global $phpbb_root_path, $phpEx, $user, $auth, $db, $config, $cache, $template;
			
			define('IN_PHPBB', true);

			$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';

			$phpEx = substr(strrchr(__FILE__, '.'), 1);

			include($phpbb_root_path . 'common.' . $phpEx);
			include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
			include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

			// Start session management

			$user->session_begin();
			$auth->acl($user->data);

			//Yeah, I know this is not needed but I did it for simplicity


			$message = "name: $name";
			$time = time();

			// note that multibyte support is enabled here
			$rawsubject = "Application";
			$my_subject	= utf8_normalize_nfc($rawsubject, '', true);
			$my_text	= utf8_normalize_nfc($message, '', true);

			// variables to hold the parameters for submit_post

			$poll = $uid = $bitfield = $options = ''; 

			generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);

			generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

			$data = array('forum_id' => 2,
						  'icon_id' => false,
						  'enable_bbcode' => true,
						  'enable_smilies' => true,
						  'enable_urls' => true,
						  'enable_sig' => true,
						  'message' => $my_text,
						  'message_md5' => md5($my_text),
						  'bbcode_bitfield' => $bitfield,
						  'bbcode_uid' => $uid,
						  'post_edit_locked' => 0,
						  'topic_title' => $my_subject,
						  'notify_set' => false,
						  'notify' => false,
						  'post_time' => 0,
						  'forum_name' => '',
						  'enable_indexing' => true,);

submit_post('post', $my_subject, $user->data['username'], POST_NORMAL, $poll, $data);
        }
i am trying to insert this function to my Application form and i cant make it work when the users click the finish button in the Application it always make a blank Thread instead of taking the data from the fields to put them in the new thread.

my application code is :

Code: Select all

<?php
    require_once('CheckoutWizard.class.php');
 
    $wizard = new CheckoutWizard();
    $action = $wizard->coalesce($_GET['action']);
 
    $wizard->process($action, $_POST, $_SERVER['REQUEST_METHOD'] == 'POST');
 
?>
<html>
  <head>
      <title>Application</title>
  </head>
</head>
<body>
    <h1>Application</h1>
 
    <?php if ($wizard->isComplete()) { ?>
 
      <p>
        The form is now complete. Clicking the button below will clear the container and start again.
      </p>
      <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>?action=<?= $wizard->resetAction ?>">
        <input type="submit" value="Start again" />
      </form>
 
    <?php } else { ?>
  <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>?action=<?= $wizard->getStepName() ?>">
        <h2><?= $wizard->getStepProperty('title') ?></h2>
 
        <?php if ($wizard->getStepName() == 'personalinfo') { ?>
<table>
            <tr>
              <td width="79"><b>Real Name</b>:</td>
              <td width="90">
                <input name="name" type="text" value="<?= htmlSpecialChars($wizard->getValue('name')) ?>" size="15" maxlength="15" />              </td>
              <td width="20">&nbsp;</td>
              <td>
                <?php if ($wizard->isError('name')) { ?>
                <?= $wizard->getError('name') ?>
                <?php } ?>              </td>
            </tr>
            <tr>
              <td><b>Location:</b></td>
              <td>
                <input name="location" type="text" value="<?= htmlSpecialChars($wizard->getValue('location')) ?>" size="15" maxlength="15" />              </td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('location')) { ?>
                  <?= $wizard->getError('location') ?>
                <?php } ?>              </td>
            </tr>
            <tr>
              <td><b>Sex:</b></td>
              <td>
                <select name="sex">
                  <option value=""></option>
                  <?php foreach ($wizard->sex as $k => $v) { ?>
                    <option value="<?= $k ?>"<?php if ($wizard->getValue('sex') == $k) { ?> selected="selected"<?php } ?>>
                      <?= $v ?>
                    </option>
                  <?php } ?>
                </select>              </td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('sex')) { ?>
                  <?= $wizard->getError('sex') ?>
                <?php } ?>              </td>
            </tr>
            <tr>
              <td><b>Age:</b></td>
              <td><input name="age" type="text" value="<?= htmlSpecialChars($wizard->getValue('age')) ?>" size="2" maxlength="2" /></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('age')) { ?>
              <?= $wizard->getError('age') ?>
              <?php } ?></td>
            </tr>
    </table>
        <p>&nbsp;</p>
<table>
  <tr>
    <td width="127"><b>Rate Your English:</b></td>
    <td width="41"><select name="eng">
      <option value=""></option>
      <?php foreach ($wizard->eng as $k => $v) { ?>
      <option value="<?= $k ?>"<?php if ($wizard->getValue('eng') == $k) { ?> selected="selected"<?php } ?>>
        <?= $v ?>
        </option>
      <?php } ?>
    </select></td>
    <td width="20">&nbsp;</td>
    <td><?php if ($wizard->isError('eng')) { ?>
                  <?= $wizard->getError('eng') ?>
      <?php } ?></td>
  </tr>
</table>

        <?php } else if ($wizard->getStepName() == 'charinfo') { ?>
<table>
            <tr>
              <td width="116"><strong>Character Name:</strong></td>
              <td width="90"><input name="igname" type="text" value="<?= htmlSpecialChars($wizard->getValue('igname')) ?>" size="15" maxlength="15" /></td>
              <td width="20">&nbsp;</td>
              <td>
                <?php if ($wizard->isError('igname')) { ?>
                  <?= $wizard->getError('igname') ?>
                <?php } ?>              </td>
            </tr>
            <tr>
              <td><strong>Race:</strong></td>
              <td><select name="race">
                <option value=""></option>
                <?php foreach ($wizard->race as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('race') == $k) { ?> selected="selected"<?php } ?>>
                <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('race')) { ?>
                  <?= $wizard->getError('race') ?>
                <?php } ?>              </td>
            </tr>
            <tr>
              <td><strong>Class::</strong></td>
              <td><select name="class">
                <option value=""></option>
                <?php foreach ($wizard->class as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('class') == $k) { ?> selected="selected"<?php } ?>>
                <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('class')) { ?>
                  <?= $wizard->getError('class') ?>
                <?php } ?>              </td>
    </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><strong>Spec:</strong></td>
              <td><input name="s1" type="text" value="<?= htmlSpecialChars($wizard->getValue('s1')) ?>" size="2" maxlength="2" />
                &bull;
                <input name="s2" type="text" value="<?= htmlSpecialChars($wizard->getValue('s2')) ?>" size="2" maxlength="2" />
                &bull;
                <input name="s3" type="text" value="<?= htmlSpecialChars($wizard->getValue('s3')) ?>" size="2" maxlength="2" /></td>
              <td>&nbsp;</td>
              <td>
			  	<?php if ($wizard->isError('s1')) { ?>
                <?= $wizard->getError('s1') ?>
                <?php } ?></td>
            </tr>
    </table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table>
  <tr>
    <td width="480"><div align="center"><b>Played Time</b></div></td>
    <td width="20">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="center">
      <input name="days" type="text" value="<?= htmlSpecialChars($wizard->getValue('days')) ?>" size="2" maxlength="3" />
      <b>Days &bull;</b>
  <input name="hours" type="text" value="<?= htmlSpecialChars($wizard->getValue('hours')) ?>" size="2" maxlength="3" />
      <b>Hours</b></div></td>
    <td>&nbsp;</td>
    <td>
		<?php if ($wizard->isError('days')) { ?>
        <?= $wizard->getError('days') ?>
      <?php } ?></td>
  </tr>
  <tr>
    <td><hr></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="center"><b>Previous Guilds</b></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input name="preguild" type="text" id="preguild" value="<?= htmlSpecialChars($wizard->getValue('preguild')) ?>" size="80" maxlength="100" /></td>
    <td>&nbsp;</td>
    <td>
		<?php if ($wizard->isError('preguild')) { ?>
        <?= $wizard->getError('preguild') ?>
      <?php } ?></td>
  </tr>
  <tr>
    <td><hr></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="center"><b>Armory Link (<a href="http:
u.wowarmory.com" target="_blank">WoW Armory</a>)</b></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input name="armory" type="text" value="<?= htmlSpecialChars($wizard->getValue('armory')) ?>" size="80" maxlength="100" /></td>
    <td>&nbsp;</td>
    <td>
		<?php if ($wizard->isError('armory')) { ?>
        <?= $wizard->getError('armory') ?>
      <?php } ?></td>
  </tr>
  <tr>
    <td><hr></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="center"><b>User Interface (UI) ScreenShot</b></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input name="ui" type="text" value="<?= htmlSpecialChars($wizard->getValue('ui')) ?>" size="80" maxlength="100" /></td>
    <td>&nbsp;</td>
    <td>
		<?php if ($wizard->isError('ui')) { ?>
        <?= $wizard->getError('ui') ?>
      <?php } ?></td>
  </tr>
  <tr>
    <td><hr></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

        <?php } else if ($wizard->getStepName() == 'raidexp') { ?>
<table>
            <tr>
              <td width="41"><select name="ssc">
                <option value=""></option>
                <?php foreach ($wizard->ssc as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('ssc') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td width="191"><b>SerpentShrine Cavern (SSC)</b></td>
              <td width="20">&nbsp;</td>
              <td>
                <?php if ($wizard->isError('ssc')) { ?>
                  <?= $wizard->getError('ssc') ?>
                <?php } ?>
              </td>
            </tr>
            <tr>
              <td><select name="mh">
                <option value=""></option>
                <?php foreach ($wizard->mh as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('mh') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td><b>Hyjal Summit (MH)</b></td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('mh')) { ?>
                  <?= $wizard->getError('mh') ?>
                <?php } ?>
              </td>
            </tr>
            <tr>
              <td><select name="bt">
                <option value=""></option>
                <?php foreach ($wizard->bt as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('bt') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td><b>Black Temple (BT)</b></td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('bt')) { ?>
                  <?= $wizard->getError('bt') ?>
                <?php } ?>
              </td>
            </tr>
            <tr>
              <td><select name="swp">
                <option value=""></option>
                <?php foreach ($wizard->swp as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('swp') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td><b>SunWell Plateau (SWP)</b></td>
              <td>&nbsp;</td>
              <td>
              	<?php if ($wizard->isError('swp')) { ?>
                  <?= $wizard->getError('swp') ?>
              <?php } ?></td>
            </tr>
    </table>
<p>&nbsp;</p>
<table>
            <tr>
              <td width="41"><select name="naxx" id="naxx">
                <option value=""></option>
                <?php foreach ($wizard->naxx as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('naxx') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td width="234"><b>Naxxramas</b></td>
              <td width="20">&nbsp;</td>
              <td><?php if ($wizard->isError('naxx')) { ?>
              <?= $wizard->getError('naxx') ?>
              <?php } ?></td>
            </tr>
            <tr>
              <td><select name="mal" id="mal">
                <option value=""></option>
                <?php foreach ($wizard->mal as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('mal') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td><b>Malygos &bull; The Eye Of Eternity</b></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('mal')) { ?>
              <?= $wizard->getError('mal') ?>
              <?php } ?></td>
            </tr>
            <tr>
              <td><select name="sar" id="sar">
                <option value=""></option>
                <?php foreach ($wizard->sar as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('sar') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td><b>Sartharion &bull; The Obsidian Sanctum</b></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('sar')) { ?>
              <?= $wizard->getError('sar') ?>
              <?php } ?></td>
            </tr>
            <tr>
              <td><select name="voa" id="voa">
                <option value=""></option>
                <?php foreach ($wizard->voa as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('voa') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td><b>Wintergrasp &bull; Vault Of Archavon</b></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('voa')) { ?>
              <?= $wizard->getError('voa') ?>
              <?php } ?></td>
            </tr>
    </table>        
        <?php } else if ($wizard->getStepName() == 'compinfo') { ?>
<table>
            <tr>
              <td width="86"><b>System:</b></td>
              <td width="61"><select name="os" id="os">
                <option value="" selected></option>
                <?php foreach ($wizard->os as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('os') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td width="20">&nbsp;</td>
              <td>
                <?php if ($wizard->isError('os')) { ?>
                  <?= $wizard->getError('os') ?>
                <?php } ?>
              </td>
            </tr>
            <tr>
              <td><b>Ventrilo:</b></td>
              <td><select name="vent" id="vent">
                <option value=""></option>
                <?php foreach ($wizard->vent as $k => $v) { ?>
                <option value="<?= $k ?>"<?php if ($wizard->getValue('vent') == $k) { ?> selected="selected"<?php } ?>>
                  <?= $v ?>
                </option>
                <?php } ?>
              </select></td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('vent')) { ?>
                  <?= $wizard->getError('vent') ?>
                <?php } ?>
              </td>
            </tr>
            <tr>
              <td><b>Microphone:</b></td>
              <td>
                <select name="mic" id="mic">
                  <option value=""></option>
                  <?php foreach ($wizard->mic as $k => $v) { ?>
                    <option value="<?= $k ?>"<?php if ($wizard->getValue('mic') == $k) { ?> selected="selected"<?php } ?>>
                      <?= $v ?>
                    </option>
                  <?php } ?>
                </select>
              </td>
              <td>&nbsp;</td>
              <td>
                <?php if ($wizard->isError('mic')) { ?>
                  <?= $wizard->getError('mic') ?>
                <?php } ?>
              </td>
            </tr>
            <tr>
              <td><b>Internet:</b></td>
              <td><input name="isp" type="text" id="isp" value="<?= htmlSpecialChars($wizard->getValue('isp')) ?>" size="4" maxlength="4" />
                <b>Mbit</b></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('isp')) { ?>
                  <?= $wizard->getError('isp') ?>
              <?php } ?></td>
            </tr>
            <tr>
              <td><b>Prossecor:</b></td>
              <td><input name="cpu" type="text" id="cpu" value="<?= htmlSpecialChars($wizard->getValue('cpu')) ?>" size="4" maxlength="4" />
              <b>Mhz</b></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('cpu')) { ?>
                  <?= $wizard->getError('cpu') ?>
              <?php } ?></td>
            </tr>
            <tr>
              <td><b>Ram:</b></td>
              <td><input name="ram" type="text" id="ram" value="<?= htmlSpecialChars($wizard->getValue('ram')) ?>" size="4" maxlength="4" />
                <b>MB</b></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('ram')) { ?>
                  <?= $wizard->getError('ram') ?>
              <?php } ?></td>
            </tr>
    </table>
<?php } else if ($wizard->getStepName() == 'extrainfo') { ?>

<table>
            <tr>
              <td width="317"><b>Do you know anyone in our Guild ?</b></td>
              <td width="20">&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><input name="guildf" type="text" id="guildf" value="<?= htmlSpecialChars($wizard->getValue('guildf')) ?>" size="50" maxlength="50" /></td>
              <td>&nbsp;</td>
              <td><?php if ($wizard->isError('guildf')) { ?>
                  <?= $wizard->getError('guildf') ?>
              <?php } ?></td>
            </tr>
            <tr>
              <td><b>Any Last Shout ?</b></td>
              <td></td>
              <td>
              </td>
            </tr>
            <tr>
              <td><textarea name="shout" cols="50" rows="4" id="shout"><?= htmlSpecialChars($wizard->getValue('shout')) ?></textarea></td>
              <td>&nbsp;</td>
              <td> <?php if ($wizard->isError('shout')) { ?>
                  <?= $wizard->getError('shout') ?>
              <?php } ?></td>
            </tr>
    </table>
        <?php } else if ($wizard->getStepName() == 'confirm') { ?>
<p>
      <b>Please verify the entered Information and then click Finish to complete your Application.</b></p>
 
    <table>
            <tr>
              <td width="156"><b>Real Name:</b></td>
              <td><?= $wizard->getValue('name') ?></td>
            </tr>
            <tr>
              <td><b>Location:</b></td>
              <td><?= $wizard->getValue('location') ?></td>
            </tr>
            <tr>
              <td><b>Sex:</b></td>
              <td><?= $wizard->getValue('sex') ?></td>
            </tr>
            <tr>
              <td><b>Age:</b></td>
              <td><?= $wizard->getValue('age') ?></td>
            </tr>
            <tr>
              <td><b>English:</b></td>
              <td><?= $wizard->getValue('eng') ?></td>
            </tr>
            <tr>
              <td><b>Character Name:</b></td>
              <td><?= $wizard->getValue('igname') ?></td>
            </tr>
            <tr>
              <td><b>Race:</b></td>
              <td><?= $wizard->getValue('race') ?></td>
            </tr>
            <tr>
              <td><b>Class:</b></td>
              <td><?= $wizard->getValue('class') ?></td>
            </tr>
            <tr>
              <td><b>Spec:</b></td>
              <td><?= $wizard->getValue('s1') ?> <b>/</b>
<?= $wizard->getValue('s2') ?> <b>/</b><?= $wizard->getValue('s3') ?></td>
            </tr>
            <tr>
              <td><b>Played:</b></td>
              <td><?= $wizard->getValue('days') ?> - <?= $wizard->getValue('hours') ?></td>
            </tr>
            <tr>
              <td><b>Previous Guilds:</b></td>
              <td><?= $wizard->getValue('preguild') ?></td>
            </tr>
            <tr>
              <td><b>Armory Link:</b></td>
              <td><?= $wizard->getValue('armory') ?></td>
            </tr>
            <tr>
              <td><b>UI ScreenShot:</b></td>
              <td><?= $wizard->getValue('ui') ?></td>
            </tr>
            <tr>
              <td><b>SSC:</b></td>
              <td><?= $wizard->getValue('ssc') ?></td>
            </tr>
            <tr>
              <td><b>MH:</b></td>
              <td><?= $wizard->getValue('mh') ?></td>
            </tr>
            <tr>
              <td><b>BT:</b></td>
              <td><?= $wizard->getValue('bt') ?></td>
            </tr>
            <tr>
              <td><b>SWP:</b></td>
              <td><?= $wizard->getValue('swp') ?></td>
            </tr>
            <tr>
              <td><b>Naxxramas:</b></td>
              <td><?= $wizard->getValue('naxx') ?></td>
            </tr>
            <tr>
              <td><b>Malygos:</b></td>
              <td><?= $wizard->getValue('mal') ?></td>
            </tr>
            <tr>
              <td><b>Sartharion:</b></td>
              <td><?= $wizard->getValue('sar') ?></td>
            </tr>
            <tr>
              <td><b>Wintergrasp:</b></td>
              <td><?= $wizard->getValue('voa') ?></td>
            </tr>
            <tr>
              <td><b>Operating System:</b></td>
              <td><?= $wizard->getValue('os') ?></td>
            </tr>
            <tr>
              <td><b>Prossecor:</b></td>
              <td><?= $wizard->getValue('cpu') ?></td>
            </tr>
            <tr>
              <td><b>Ram:</b></td>
              <td><?= $wizard->getValue('ram') ?></td>
            </tr>
            <tr>
              <td><b>Internet Connection:</b></td>
              <td><?= $wizard->getValue('isp') ?></td>
            </tr>
            <tr>
              <td><b>Ventrilo:</b></td>
              <td><?= $wizard->getValue('vent') ?></td>
            </tr>
            <tr>
              <td><b>Microphone:</b></td>
              <td><?= $wizard->getValue('mic') ?></td>
            </tr>
            <tr>
              <td><b>Know Anyone In Guild:</b></td>
              <td><?= $wizard->getValue('guildf') ?></td>
            </tr>
            <tr>
              <td><b>Any Last Shout:</b></td>
              <td><?= $wizard->getValue('shout') ?></td>
            </tr>
      </table>
    <?php } ?>
 
    <p>
  <input type="submit" 
                 name="previous" 
                 value="<< Previous"<?php if ($wizard->isFirstStep()) { ?> style="visibility:hidden" <?php } ?> />
          <input type="submit" 
                 value="<?= $wizard->isLastStep() ? 'Apply' : 'Next' ?> >>"  />
        </p>
      </form>
    <?php } ?>
  </body>
</html>
I am trying days now and i cant seem to work it out :( Any tips ?

ty in advance!
User avatar
Nelsaidi
Registered User
Posts: 525
Joined: Mon Feb 11, 2008 1:59 pm
Location: London, UK
Contact:

Re: issues with adding a function

Post by Nelsaidi »

You have to ECHO the file, so, use the below for the form action.

Code: Select all

<?= echo $_SERVER['PHP_SELF']; ?>
Image
Click here to find out what eRepublik is.
pixel001
Registered User
Posts: 100
Joined: Thu Aug 23, 2007 11:38 am

Re: issues with adding a function

Post by pixel001 »

you're mixing alot of html in your function. the proper way would be to send a content array to your template like here.

ps we're working on something similar : http://www.bbdkp.net/viewtopic.php?f=36&t=629

hth
gnarlita
Registered User
Posts: 4
Joined: Fri Jan 16, 2009 6:26 am

Re: issues with adding a function

Post by gnarlita »

as you saw my Application Form is intergrating with

Code: Select all

    require_once('CheckoutWizard.class.php');
CheckoutWizard.class.php

Code: Select all

<?php
    require_once('ZervWizard.class.php');
 
    class CheckoutWizard extends ZervWizard
    {
        function CheckoutWizard()
        {
            // start the session and initialize the wizard
            session_start();
            parent::ZervWizard($_SESSION, __CLASS__);
 
 
            // create the steps
            $this->addStep('personalinfo', 'Personal Information');
            $this->addStep('charinfo', 'Character Information');
			$this->addStep('raidexp', 'Raid Experience');
			$this->addStep('compinfo', 'Computer Information');
			$this->addStep('extrainfo', 'Extra Information');
            $this->addStep('confirm', 'Confirm your details');
			$this->addStep('terms', 'Terms and Conditions');
        }
 
        // here we prepare the personal info step.
 
        function prepare_personalinfo()
        {
            $this->loadsex();
			$this->loadeng();
        }
 
        // now we process the first step.
 
        function process_personalinfo(&$form)
        {
            $name = $this->coalesce($form['name']);
            if (strlen($name) > 0)
                $this->setValue('name', $name);
            else
                $this->addError('name', '<img src="images/left.gif"> Your Name is recuired');
 
            $location = $this->coalesce($form['location']);
            if (strlen($location) > 0)
                $this->setValue('location', $location);
            else
                $this->addError('location', '<img src="images/left.gif"> Your Location is recuired');
 
            $sex = $this->coalesce($form['sex']);
            $this->loadsex();
            if (array_key_exists($sex, $this->sex))
                $this->setValue('sex', $sex);
            else
                $this->addError('sex', '<img src="images/left.gif"> Please select your Sex');
 
			$age = $this->coalesce($form['age']);
            if (strlen($age) > 0)
                $this->setValue('age', $age);
            else
                $this->addError('age', '<img src="images/left.gif"> Please enter your Age');
 
			$eng = $this->coalesce($form['eng']);
            $this->loadeng();
            if (array_key_exists($eng, $this->eng))
                $this->setValue('eng', $eng);
			else
                $this->addError('eng', '<img src="images/left.gif"> Please Rate your English');
 
            return !$this->isError();
        }
 
        // next step prepare
 
        function prepare_charinfo()
        {
            $this->loadrace();
			$this->loadclass();
			$this->loadclass2();
			$this->loadclass3();
        }
 
        // the proccess
 
        function process_charinfo(&$form)
        {
            $igname = $this->coalesce($form['igname']);
            if (strlen($igname) > 0)
                $this->setValue('igname', $igname);
            else
                $this->addError('igname', '<img src="images/left.gif"> Your Character Name is recuired');
 
            $race = $this->coalesce($form['race']);
            $this->loadrace();
            if (array_key_exists($race, $this->race))
                $this->setValue('race', $race);
            else
                $this->addError('race', '<img src="images/left.gif"> Please select your Race');
 
            $class = $this->coalesce($form['class']);
            $this->loadclass();
            if (array_key_exists($class, $this->class))
                $this->setValue('class', $class);
			else
 				$this->addError('class', '<img src="images/left.gif"> Please select your Class');
 
			$s1 = $this->coalesce($form['s1']);
            if (strlen($s1) > 0)
                $this->setValue('s1', $s1);
            else
                $this->addError('s1', '<img src="images/left.gif"> Please enter your Spec');
				
			$s2 = $this->coalesce($form['s2']);
            if (strlen($s2) > 0)
                $this->setValue('s2', $s2);
            else
                $this->addError('s2', '<img src="images/left.gif"> Please enter your Spec');
				
			$s3 = $this->coalesce($form['s3']);
            if (strlen($s3) > 0)
                $this->setValue('s3', $s3);
            else
                $this->addError('s3', '<img src="images/left.gif"> Please enter your Spec');
 
 			$days = $this->coalesce($form['days']);
            if (strlen($days) > 0)
                $this->setValue('days', $days);
            else
                $this->addError('days', '<img src="images/left.gif"> Please enter your Played Days');
 
			$hours = $this->coalesce($form['hours']);
            if (strlen($hours) > 0)
                $this->setValue('hours', $hours);
            else
                $this->addError('hours', '<img src="images/left.gif"> Please enter your Played Hours');
 
			$preguild = $this->coalesce($form['preguild']);
            if (strlen($preguild) > 0)
                $this->setValue('preguild', $preguild);
            else
                $this->addError('preguild', '<img src="images/left.gif"> Please enter your Previous Guilds (if you havent been in any type: None)');
 
			$armory = $this->coalesce($form['armory']);
            if (strlen($armory) > 0)
                $this->setValue('armory', $armory);
            else
                $this->addError('armory', '<img src="images/left.gif"> Please enter your Armory Link');
 
			$ui = $this->coalesce($form['ui']);
            if (strlen($ui) > 0)
                $this->setValue('ui', $ui);
            else
                $this->addError('ui', '<img src="images/left.gif"> Please enter your UI Link (you can Go to <a href="http://www.imageshack.us" target="_blank">Imageshack</a> or <a href="http://www.photobucket.com" target="_blank">Photobucket</a> to upload an image');

			return !$this->isError();
        }

        // next step prepare

 		function prepare_raidexp()
        {
			$this->loadssc();
			$this->loadmh();
			$this->loadbt();
			$this->loadswp();
			$this->loadnaxx();
			$this->loadmal();
			$this->loadsar();
			$this->loadvoa();
        }
		

        // process

		function process_raidexp(&$form)
        {
			$ssc = $this->coalesce($form['ssc']);
            $this->loadssc();
            if (array_key_exists($ssc, $this->ssc))
                $this->setValue('ssc', $ssc);
            else
                $this->addError('ssc', '<img src="images/left.gif"> Please select your SSC Experience');
 
			$mh = $this->coalesce($form['mh']);
            $this->loadmh();
            if (array_key_exists($mh, $this->mh))
                $this->setValue('mh', $mh);
            else
                $this->addError('mh', '<img src="images/left.gif"> Please select your MH Experience');
 
			$bt = $this->coalesce($form['bt']);
            $this->loadbt();
            if (array_key_exists($bt, $this->bt))
                $this->setValue('bt', $bt);
            else
                $this->addError('bt', '<img src="images/left.gif"> Please select your BT Experience');
 
			$swp = $this->coalesce($form['swp']);
            $this->loadswp();
            if (array_key_exists($swp, $this->swp))
                $this->setValue('swp', $swp);
            else
                $this->addError('swp', '<img src="images/left.gif"> Please select your SWP Experience');

			$naxx = $this->coalesce($form['naxx']);
			$this->loadnaxx();
            if (array_key_exists($naxx, $this->naxx))
                $this->setValue('naxx', $naxx);
            else
                $this->addError('naxx', '<img src="images/left.gif"> Please select your Naxxramas Experience');

			$mal = $this->coalesce($form['mal']);
			$this->loadmal();
            if (array_key_exists($mal, $this->mal))
                $this->setValue('mal', $mal);
            else
                $this->addError('mal', '<img src="images/left.gif"> Please select your Malygos • The Eye Of Eternity Experience');

			$sar = $this->coalesce($form['sar']);
			$this->loadsar();
            if (array_key_exists($sar, $this->sar))
                $this->setValue('sar', $sar);
            else
                $this->addError('sar', '<img src="images/left.gif"> Please select your Sartharion • The Obsidian Sanctum Experience');

			$voa = $this->coalesce($form['voa']);
			$this->loadvoa();
            if (array_key_exists($voa, $this->voa))
                $this->setValue('voa', $voa);
            else
                $this->addError('voa', '<img src="images/left.gif"> Please select your Wintergrasp • Vault Of Archavon Experience');

            return !$this->isError();
        }

        // next step prepare

		function prepare_compinfo()
        {
			$this->loados();
			$this->loadvent();
			$this->loadmic();
        }

        // process

		function process_compinfo(&$form)
        {
			$os = $this->coalesce($form['os']);
            $this->loados();
            if (array_key_exists($os, $this->os))
                $this->setValue('os', $os);
            else
                $this->addError('os', '<img src="images/left.gif"> Please select your Operating System');
 
			$vent = $this->coalesce($form['vent']);
            $this->loadvent();
            if (array_key_exists($vent, $this->vent))
                $this->setValue('vent', $vent);
            else
                $this->addError('vent', '<img src="images/left.gif"> Please select your Answer');
 
			$mic = $this->coalesce($form['mic']);
            $this->loadmic();
            if (array_key_exists($mic, $this->mic))
                $this->setValue('mic', $mic);
            else
                $this->addError('mic', '<img src="images/left.gif"> Please select your Answer');
 
			$isp = $this->coalesce($form['isp']);
            if (strlen($isp) > 0)
                $this->setValue('isp', $isp);
            else
                $this->addError('isp', '<img src="images/left.gif"> Type Your internet connection Speed');
 
			$cpu = $this->coalesce($form['cpu']);
            if (strlen($cpu) > 0)
                $this->setValue('cpu', $cpu);
            else
                $this->addError('cpu', '<img src="images/left.gif"> Type your Prossecor Speed');
 
			$ram = $this->coalesce($form['ram']);
            if (strlen($ram) > 0)
                $this->setValue('ram', $ram);
            else
                $this->addError('ram', '<img src="images/left.gif"> Type how mutch Ram you have');
 
            return !$this->isError();
        }

        // next step prepare

		function prepare_extrainfo()
        {
        }
		
		function process_extrainfo(&$form)
        {
			$guildf = $this->coalesce($form['guildf']);
            if (strlen($guildf) > 0)
                $this->setValue('guildf', $guildf);
            else
                $this->addError('guildf', '<img src="images/left.gif"> If you dont know anyone just Type: None');
 
            $shout = $this->coalesce($form['shout']);
            if (strlen($shout) > 0)
                $this->setValue('shout', $shout);
            else
                $this->addError('shout', '<img src="images/left.gif"> Type anything you want /use brain = on!');
 
            return !$this->isError();
        }
		
        // the final step is the confirmation step. there's nothing to prepare here
        // as we're just asking for final acceptance from the user
 
        function process_confirm(&$form)
        {
			global $phpbb_root_path, $phpEx, $user, $auth, $db, $config, $cache, $template;
			
			define('IN_PHPBB', true);

			$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';

			$phpEx = substr(strrchr(__FILE__, '.'), 1);

			include($phpbb_root_path . 'common.' . $phpEx);
			include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
			include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

			// Start session management

			$user->session_begin();
			$auth->acl($user->data);

			//Yeah, I know this is not needed but I did it for simplicity


			$message = "name: $name";
			$time = time();

			// note that multibyte support is enabled here
			$rawsubject = "Application";
			$my_subject	= utf8_normalize_nfc($rawsubject, '', true);
			$my_text	= utf8_normalize_nfc($message, '', true);

			// variables to hold the parameters for submit_post

			$poll = $uid = $bitfield = $options = ''; 

			generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);

			generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

			$data = array('forum_id' => 2,
						  'icon_id' => false,
						  'enable_bbcode' => true,
						  'enable_smilies' => true,
						  'enable_urls' => true,
						  'enable_sig' => true,
						  'message' => $my_text,
						  'message_md5' => md5($my_text),
						  'bbcode_bitfield' => $bitfield,
						  'bbcode_uid' => $uid,
						  'post_edit_locked' => 0,
						  'topic_title' => $my_subject,
						  'notify_set' => false,
						  'notify' => false,
						  'post_time' => 0,
						  'forum_name' => '',
						  'enable_indexing' => true,);

submit_post('post', $my_subject, $user->data['username'], POST_NORMAL, $poll, $data);
        }
 
 
        /**
         * Miscellaneous utility functions
         */
 
 
        function loadsex()
        {
            $this->sex = array('Male' => 'Male',
                               'Female' => 'Female');
        }
		
		function loadeng()
        {
            $this->eng = array('1/10' => '1/10',
							   '2/10' => '2/10',
							   '3/10' => '3/10',
							   '4/10' => '4/10',
							   '5/10' => '5/10',
							   '6/10' => '6/10',
							   '7/10' => '7/10',
							   '8/10' => '8/10',
							   '9/10' => '9/10',
							   'English is my Middle Name!' => 'Excellent');
        }
 
        function loadrace()
        {
            $this->race = array('Orc' => 'Orc',
                                'Tauren' => 'Tauren',
								'Undead' => 'Undead',
								'Troll' => 'Troll',
								'Blood Elf' => 'Blood Elf');
        }
		
		function loadclass()
        {
			 	$this->class = array('Death Knight' => 'Death Knight',
                                 'Druid' => 'Druid',
								 'Hunter' => 'Hunter',
								 'Mage' => 'Mage',
								 'Paladin' => 'Paladin',
								 'Priest' => 'Priest',
								 'Rogue' => 'Rogue',
								 'Shaman' => 'Shaman',
								 'Warlock' => 'Warlock',
								 'Warrior' => 'Warrior');
        }
		
		function loadclass2()
        {
			 	$this->class2 = array('Death Knight' => 'Death Knight',
								 'Warlock' => 'Warlock',
								 'Warrior' => 'Warrior');
        }
		
		function loadclass3()
        {
			 	$this->class3 = array('Death Knight' => 'Death Knight',
                                 'Druid' => 'Druid',
								 'Hunter' => 'Hunter',
								 'Warrior' => 'Warrior');
        }
		
		function loadssc()
        {
            $this->ssc = array('None' => 'None',
                               '1/6' => '1/6',
							   '2/6' => '2/6',
							   '3/6' => '3/6',
							   '4/6' => '4/6',
							   '5/6' => '5/6',
							   'Full' => 'Full');
        }
		
		function loadmh()
        {
            $this->mh = array('None' => 'None',
                               '1/5' => '1/6',
							   '2/5' => '2/6',
							   '3/5' => '3/6',
							   '4/5' => '4/6',
							   'Full' => 'Full');
        }
		
		function loadbt()
        {
            $this->bt = array('None' => 'None',
                               '1/9' => '1/6',
							   '2/9' => '2/6',
							   '3/9' => '3/6',
							   '4/9' => '4/6',
							   '5/9' => '5/6',
							   '6/9' => '6/9',
							   '7/9' => '7/9',
							   '8/9' => '8/9',
							   'Full' => 'Full');
        }
		
		function loadswp()
        {
            $this->swp = array('None' => 'None',
                               '1/6' => '1/6',
							   '2/6' => '2/6',
							   '3/6' => '3/6',
							   '4/6' => '4/6',
							   '5/6' => '5/6',
							   'Full' => 'Full');
        }
		
		function loados()
        {
            $this->os = array('Windows' => 'Windows',
                               'MacOs' => 'MacOS');
        }
		
		function loadvent()
        {
            $this->vent = array('Yes' => 'Yes',
                               'No' => 'No');
        }
		
		function loadmic()
        {
            $this->mic = array('No' => 'No',
                               'Yes' => 'Yes');
        }
		
		function loadnaxx()
        {
            $this->naxx = array('None' => 'None',
                               'Only 10 Man' => '10man',
							   'Only 25 Man' => '25man',
							   'Full exp 10man and 25man' => 'Both');
        }
		
		function loadmal()
        {
            $this->mal = array('None' => 'None',
                               'Only 10 Man' => '10man',
							   'Only 25 Man' => '25man',
							   'Full exp 10man and 25man' => 'Both');
        }
		
		function loadsar()
        {
            $this->sar = array('None' => 'None',
                               'Only 10 Man' => '10man',
							   'Only 25 Man' => '25man',
							   'Full exp 10man and 25man' => 'Both');
        }
		
		function loadvoa()
        {
            $this->voa = array('None' => 'None',
                               'Only 10 Man' => '10man',
							   'Only 25 Man' => '25man',
							   'Full exp 10man and 25man' => 'Both');
        }
    }
?>
i have managed to make the Application Form work correctly i just cant make the function work properly so the information inputed in the fields gets posted in a new thread in my Forum.
Locked

Return to “[3.0.x] MOD Writers Discussion”