← Joomla

Formulário de registo - AlphaRegistration (PHP)

Lida 4567 vezes

Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Boa tarde,


Estou utilizando o componente: AlphaRegistration para o formulário de registo do meu site...

Mas eu gostava de fazer uma pequena modificação na sua interface, mas não estou conseguindo...



O que pretendia fazer era apagar o campo "Nome:" e quando os dados, da conta do utilizador, entrarem na Base de Dados, o "Nome" era substituído pelo "Nome de utilizador" que foi preenchido no formulário.


Exemplo:

O utilizador regista-te com os seguinte dados:

Nome de Utilizador: TESTE

Logo os seus dados vão entrar na base de dados, deste modo:

Nome: TESTE

Nome de Utilizador: TESTE


Código:

Código referente ao campo "Nome":

Código: (php) [Seleccione]
<tr valign="top">
<td width="140" height="40">
<label for="name">
<?php echo JText::_'Nome' ); ?>:
</label>
</td>
  <td>
  <input type="text" name="name" id="name" size="30" value="<?php if ( @$this->post['name'] ) echo @$this->post['name'] ; ?>" maxlength="50" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;margin-left:6px;" />
  * <span id="statusNAME"></span>
  </td>
</tr>



Código referente ao campo "Nome de Utilizador":

Código: (php) [Seleccione]
<tr valign="top">
<td height="40">
<label for="username">
<?php echo JText::_'Username' ); ?>:
</label>
</td>
<td>
<input type="text" id="username" name="username" size="30" value="<?php if ( @$this->post['username'] ) echo @$this->post['username'] ; ?>" maxlength="25" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" autocomplete="off" onPaste="alert('<?php echo JText::_'ARG_SORRY_THIS_FUNCTIONALITY_IS_DISABLED' ); ?>');return false;" style="width:220px;margin-left:6px;" />
* <span id="statusUSR"></span>
</td>
</tr>



Código do formulário (todo):

Código: (php) [Seleccione]
<?php 
/**
 * @version 2.0.12 alpharegistration $
 * @package alpharegistration
 * @copyright Copyright © 2009-2010 - Bernard Gilly - All rights reserved.
 * @license GNU/GPL
 * @author Bernard Gilly
 * @author mail contact@alphaplug.com
 * @website www.alphaplug.com
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

if (
$this->arg_params->get'displaytermslink')) {
$url  'http://www.lusonetwork.net/docs/termos-e-condicoes';
$status 'menubar=yes,scrollbars=yes,resizable=yes';
$text JText::_('ARG_READ_TERMS_OF_USE');
$attribsr['title'] = JText::_'ARG_READ_TERMS_OF_USE' );
$attribsr['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
$linktoterms JHTML::_('link'JRoute::_($url), $text$attribsr);
} else 
$linktoterms "";

if ( 
$this->post=='' $this->post=array();
if ( @
$this->post['referraluser']=='' && $this->referreid!='' ) @$this->post['referraluser']=$this->referreid;
?>

<script type="text/javascript">
function checktermsbox() {
if (document.josFormARG.terms.checked == true ) {
document.josFormARG.submitter.disabled = false;
} else {
document.josFormARG.submitter.disabled = true;
}
}
</script>
<?php
include_once (JPATH_COMPONENT.DS.'assets'.DS.'modules'.DS.'headermodule1.php');
 
if ( 
$this->arg_params->get'displayheaderstep') ) {
?>

<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane<?php echo $this->arg_params->get'pageclass_sfx' ); ?>">
<tr>
<td>
<div align="center">
<?php
$folderstep1 'components/com_alpharegistration/assets/images';
$filenamestep1 'stepbystep1.png';
// import if file exists
$fileroute1 =(JPATH_COMPONENT.DS.'assets'.DS.'images'.DS.''.$this->lang.''.DS.''.$filenamestep1.'');
if (file_exists($fileroute1)) {
echo JHTML::image(JRoute::_("$folderstep1/".$this->lang."/$filenamestep1"), JText::_'ARG_GET_INVOLVED'  ) );
} else {
echo JHTML::image(JRoute::_("$folderstep1/en-gb/$filenamestep1"), JText::_'ARG_GET_INVOLVED'  ) );
if ( $this->arg_params->get'enabledMessagesLang' ) ) {
echo "<dl id=\"system-message\"><dt class=\"error\"></dt><dd class=\"error message fade\"><ul><li><strong>ERROR:</strong><br/>The Specific Language Image $fileroute1 does not exist.<br/>Now we use the English Picture as Standard<br />Info: active Language: ".$this->lang."<br />Please make a own picture in a Sub Folder in com_alpharegistration/assets/images called ".$this->lang." and name the file: $filenamestep1</li></ul></dd></dl>";
}
}
?>

</div>
<br />
</td>
</tr>
</table>
<?php ?>
<?php
if(isset(
$this->message)){
$this->display('message');
}
?>

<form action="<?php echo JRoute::_'index.php' );?>" method="post" id="josFormARG" name="josFormARG" >
<?php if ( $this->arg_params->get'show_page_title') ) { ?>
<div class="componentheading<?php echo $this->arg_params->get'pageclass_sfx' ); ?>">
<?php 
if ( 
$this->params->get('page_title') ) {
echo $this->escape($this->params->get('page_title'));
} else echo JText::_'ARG_REGISTRATION' );
?>

</div>
<br />
<?php ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane<?php echo $this->arg_params->get'pageclass_sfx' ); ?>">
<tr valign="top">
<td width="140" height="40">
<label for="name">
<?php echo JText::_'Nome' ); ?>:
</label>
</td>
  <td>
  <input type="text" name="name" id="name" size="30" value="<?php if ( @$this->post['name'] ) echo @$this->post['name'] ; ?>" maxlength="50" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;margin-left:6px;" />
  * <span id="statusNAME"></span>
  </td>
</tr>
<?php if ( !$this->arg_params->get'emailAsUsername')) { ?>
<tr valign="top">
<td height="40">
<label for="username">
<?php echo JText::_'Username' ); ?>:
</label>
</td>
<td>
<input type="text" id="username" name="username" size="30" value="<?php if ( @$this->post['username'] ) echo @$this->post['username'] ; ?>" maxlength="25" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" autocomplete="off" onPaste="alert('<?php echo JText::_'ARG_SORRY_THIS_FUNCTIONALITY_IS_DISABLED' ); ?>');return false;" style="width:220px;margin-left:6px;" />
* <span id="statusUSR"></span>
</td>
</tr>
<?php ?>
<tr valign="top">
<td height="40">
<label for="email">
<?php echo JText::_'Email' ); ?>:
</label>
</td>
<td>
<input type="text" id="email" name="email" size="30" value="<?php if ( @$this->post['email'] ) echo @$this->post['email'] ; ?>" maxlength="100" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;margin-left:6px;" />
* <span id="statusEMAIL"></span>
</td>
</tr>
<?php if ( $this->arg_params->get'forceToCheckEmail') ) : ?>
<tr valign="top">
<td height="40">
<label for="email2">
<?php echo JText::_'ARG_VERIFY_EMAIL' ); ?>:
</label>
</td>
<td>
<input type="text" id="email2" name="email2" size="30" value="<?php if ( @$this->post['email2'] ) echo @$this->post['email2'] ; ?>" maxlength="100" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" autocomplete="off" onPaste="alert('<?php echo JText::_'ARG_SORRY_THIS_FUNCTIONALITY_IS_DISABLED' ); ?>');return false;" style="width:220px;margin-left:6px;" />
* <span id="statusEMAIL2"></span>
</td>
</tr>
<?php endif; ?>
<?php if ( $this->arg_params->get'displaybirthdateAUP') ) : ?>
<tr valign="top">
  <td height="40"><?php echo JText::_'ARG_BIRTHDATE' ); ?>: </td>
  <td><?php echo JHTML::_('calendar', @$this->post['birthdate'], 'birthdate''birthdate''%Y-%m-%d', array('class'=>'inputbox''size'=>'10',  'maxlength'=>'10''style'=>'margin-left:6px;')); ?>
  <?php if ( $this->arg_params->get'displaybirthdateAUP' )=='2' ) echo '*'?><br />
  <span class="small" style="margin-left:6px;"><i><?php echo JText::_'ARG_BIRTHDATE_FORMAT' ); ?></i></span>
</td>
</tr>
<?php endif; ?>
<?php if ( $this->arg_params->get'displaygenderAUP') ) : ?>
<tr valign="top">
  <td height="40"><?php echo JText::_'ARG_GENDER' ); ?>: </td>
  <td>
    <label>
    <input id="gender" name="gender" type="radio" value="1" checked>
  <?php echo JText::_'ARG_MALE' ); ?></label>
    <label>
    <input type="radio" id="gender" name="gender" value="2">
  <?php echo JText::_'ARG_FEMALE' ); ?></label>
</td>
</tr>
<?php endif; ?>
<tr valign="top">
<td height="40">
<label for="password">
<?php echo JText::_'Password' ); ?>:
</label>
</td>
  <td><?php if ( $this->arg_params->get('show_passwordstrength') ) { ?>
<div style="width:340px;padding:6px; margin-bottom:6px;">
<?php ?>
<input type="password" id="password" name="password" size="30" value="<?php if ( @$this->post['password'] ) echo @$this->post['password'] ; ?>" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;" />
<?php if ( !$this->arg_params->get('show_passwordstrength') ) { ?>
&nbsp;*&nbsp;<span id="statusPASSWORD"></span></div>
<?php ?>
  </td>
</tr>
<tr valign="top">
  <td height="40"><label for="password2"> <?php echo JText::_'Verificar senha' ); ?>: </label>
  </td>
  <td><input type="password" id="password2" name="password2" size="30" value="<?php if ( @$this->post['password2'] ) echo @$this->post['password2'] ; ?>" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" autocomplete="off" onPaste="alert('<?php echo JText::_'ARG_SORRY_THIS_FUNCTIONALITY_IS_DISABLED' ); ?>');return false;" style="width:220px;margin-left:6px;" />
    * <span id="statusPASSWORD2"></span>
  </td>
</tr>
<?php if ( $this->arg_params->get'displayreferralcodeAUP') ) : ?>
<tr valign="top">
  <td height="40"><label for="referrer"> <?php echo JText::_'ARG_REFERRAL_CODE' ); ?>: </label>
  </td>
  <td><input type="text" id="referraluser" name="referraluser" size="30" value="<?php  if ( @$this->post['referraluser'] ) echo @$this->post['referraluser'] ; ?>" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;margin-left:6px;" />
  <?php if ( $this->arg_params->get'displayreferralcodeAUP' )=='2' ) echo '*'?>
  <span id="statusREFERRAL"></span>
      <?php if ( $this->arg_params->get'displayreferralcodeAUP' )=='1' ) { ?><br />
      <span class="small" style="margin-left:6px;"><i><?php echo JText::_'ARG_REFERRAL_CODE_DESCRIPTION' ); ?></i></span><?php ?></td>
</tr>
<?php endif; ?>
<?php if ( $this->arg_params->get'displaycouponcodeAUP') ) : ?>
<tr valign="top">
  <td height="40"><label for="couponcode"> <?php echo JText::_'ARG_COUPON_CODE' ); ?>: </label>
  </td>
  <td><input type="text" id="couponcode" name="couponcode" size="30" value="<?php if ( @$this->post['couponcode'] ) echo @$this->post['couponcode'] ; ?>" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;margin-left:6px;" />
  <?php if ( $this->arg_params->get'displaycouponcodeAUP' )=='2' ) echo '*'?>
  <span id="statusCOUPONCODE"></span><?php if ( $this->arg_params->get'displaycouponcodeAUP' )=='1' ) { ?><br />
  <span class="small" style="margin-left:6px;"><i><?php echo JText::_'ARG_COUPON_CODE_DESCRIPTION' ); ?></i></span><?php ?></td>
</tr>
<?php endif; ?>
<?php 
$buttondisabled 
"";
if ( 
$this->arg_params->get'displaytermsofuse') ) {
if ( !$this->arg_params->get'displaytermslink') || !$this->arg_params->get'idpageterms') ) {
?>

<tr valign="top">
  <td height="40"><label for="termsofuse"> <?php echo JText::_'ARG_TERMS' ); ?>: </label></td>
  <td><textarea id="termsofuse" name="termsofuse" cols="40" rows="4" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" readonly="readonly" style="width:340px;margin-left:6px;" ><?php echo JText::_'ARG_TERMS_OF_USE_TEXT' ); ?></textarea></td>
</tr>
<?php } else { ?>
<tr valign="top">
  <td height="20">&nbsp;</td>
  <td><?php echo $linktoterms ?></td>
</tr>
<?php ?>
<tr valign="top">
  <td height="40">&nbsp;</td>
  <td><input type="checkbox" id="terms" name="terms" value="terms" onclick="checktermsbox();" style="margin-left:3px;margin-top:3px;" /> <label for="terms"><?php echo JText::_'ARG_AGREE_TO_TERMS' ); ?></label><br /><br /></td>
</tr>
<?php
$buttondisabled 
' disabled="disabled"';
}
 
  if ( 
$this->arg_params->get'userecaptcha') ) : 
  
  
?>

<tr>
<td height="40">&nbsp;</td>
<td>
<?php 
if ( $this->arg_params->get'recaptchaajax ') ) {
echo '<div id="recaptcha_div"></div>';
} else {
// prevent recaptchalib already loaded
if ( !function_exists('_recaptcha_qsencode') ) {
require_once (JPATH_SITE.DS.'components'.DS.'com_alpharegistration'.DS.'assets'.DS.'recaptcha'.DS.'recaptchalib.php');
}
// Get a key from http://recaptcha.net/api/getkey
$publickey $this->arg_params->get'pubkey' );
// the response from reCAPTCHA
$resp null;
// the error code from reCAPTCHA, if any
$error null;
echo recaptcha_get_html($publickey$error);
}
?>

</td>
</tr>
<?php endif; ?>
<tr>
<td height="40">&nbsp;</td>
<td>
<button id="submitter" type="submit" class="button<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="margin-left:6px;" <?php echo $buttondisabled?>><?php echo JText::_('Concluir registo'); ?></button>
</td>
</tr>
<tr>
<td colspan="2" height="40">
<?php echo JText::_'REGISTER_REQUIRED' ); ?>
</td>
</tr>
</table>
<input type="hidden" name="option" value="com_alpharegistration" />
<input type="hidden" name="task" value="register_save" />
<input type="hidden" name="id" value="0" />
<input type="hidden" name="gid" value="0" />
<?php 
if ( !
$this->arg_params->get'forceToCheckEmail') ) {
?>

<input type="hidden" name="email2" value="" />
<?php

?>

<?php if ( $this->arg_params->get'emailAsUsername')) { ?>
<input type="hidden" name="username" value="" />
<?php
}
?>

<?php echo JHTML::_'form.token' ); ?>
</form>
<div class="clr"></div>
<?php
// include now for the step1 page the footer modulespositions
include_once (JPATH_COMPONENT.DS.'assets'.DS.'modules'.DS.'footermodule1.php');
?>

<div class="clr"></div>



Desde já muito obrigado.
Offline

mestreamateur 
Membro
Mensagens 671 Gostos 0
Feedback +1

Troféus totais: 31
Trófeus: (Ver todos)
Level 6 Avatar Tenth year Anniversary Nineth year Anniversary Windows User Super Combination Combination Topic Starter Poll Voter Poll Starter

Experimenta colocar como comentários a linha de código correspondente ao nome de utilizador e meter em vez de Nome metes Nome de Utilizador.

Depois experimenta registar-te e a ver se as duas ficam iguais, fiz isso no CBuilder e resultou.

Alterar o código não me parece ser difícil, mas infelizmente de php percebo pouco
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

@mestreamateur é uma boa ideia, mas não resultou, porque ele pede pelo Nome..

Eu penso que qualquer programador faz isso na boa, mas eu neste momento não tenho bases suficientes em PHP... :(


Obrigado pela ajuda mestreamateur.
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Alguém?
Offline

bonsempregos 
Membro
Mensagens 2008 Gostos 7
Feedback +3

Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

não precisas ter conhecimentos em php é HTML básico porque é apenas  uma form, o que tens de fazer é colocar o campo como hidden e a varável que ele manda ser igual ao do campo que queres repetir.

Tenta procurar no w3school ou google por form fields e fazer isso sozinho.

Se te vires enrascado e APENAS depois de tentares eu venho aqui ajudar-te com a solução. (desta forma aprendes a fazer por ti)
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Já tentei isso e não resultou, coloquei @$this->post['name'] para @$this->post['username] não resultou, removi simplesmente o código mas não resultou, escondi o formulário mas não resultou, tentei isto: @$this->post['name']['username] mas não resultou, mudei o name="name" para name="username" mas não resultou.

Todas essas mudanças me deram o mesmo erro: "O nome deve ter pelo menos 4 caracteres."

O que significa que ele precisa do campo "Nome" para enviar para a Base de Dados.



Eu antes de vir criar o tópico, já tinha tentado isto tudo e mais umas coisas (que é melhor nem mencionar :P ) mas não consegui o resultado pretendido, como tal, criei o tópico.
Offline

bonsempregos 
Membro
Mensagens 2008 Gostos 7
Feedback +3

Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Experimetna lá trocar na linha 89 para isto:

Código: [Seleccione]
<input type="hidden" name="name" id="name" size="30" value="<?php if ( @$this->post['username'] ) echo @$this->post['username'] ; ?>" maxlength="50" class="inputbox<?php echo $this->arg_params->get'pageclass_sfx' ); ?>" style="width:220px;margin-left:6px;" />
e diz-me se te dá algum erro
Offline

Carlos Faria 
Membro
Mensagens 551 Gostos 5
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Engraçado... :P

Estava a colocar o type="hidden", mas esqueci-me de mudar as variáveis (como disseste)...   #-o


Muito Obrigado.
Offline

bonsempregos 
Membro
Mensagens 2008 Gostos 7
Feedback +3

Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

Como vê era uma coisa muito simples e tinhas as dicas todas para a resolveres.

Fico contente que já esteja a funcionar. :)