1
noo-b
dropdown menu in register.php
  • 2007/11/17 21:21

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


i modified the edituser.php to change user_icq to sex...

here's what i change in edituser.php

$icq_text = new XoopsFormSelect(Sex'user_icq'$xoopsUser->getVar('user_icq'));
$icq_text->addOptionArray(array('Male'=>Male'Female'=>Female));


The option display successfully in edituser.php & in userinfo

so now i want to include this option in register.php here's what i've done so far...

in include/registerform.php
i put this
$reg_form->addElement(new XoopsFormSelect(Sex'user_icq'$user_icq));



in register.php
i use this to display the sex option in register.php

$user_icq = (isset($_POST['user_icq']) && intval($_POST['user_icq']));

This result an empty drop down.....

how to modify this last line of code so it will display the drop down option Male and Female

$user_icq = (isset($_POST['user_icq']) && intval($_POST['user_icq']));
thanks
I Love Xoops

2
noo-b
Re: dropdown menu in register.php
  • 2007/11/22 1:51

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


Bump
I Love Xoops

3
phppp
Re: dropdown menu in register.php
  • 2007/11/22 2:13

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


$icq_text = new XoopsFormSelect("Sex"'user_icq'$user_icq);
$icq_text->addOptionArray(array('Male'=>Male'Female'=>Female));

$reg_form->addElement($icq_text);

4
noo-b
Re: dropdown menu in register.php
  • 2007/11/22 6:09

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


post edit----------------

...i put this in include/registerform.php

$icq_text = new XoopsFormSelect("Sex"'user_icq'$user_icq);
$icq_text->addOptionArray(array('Male'=>Male'Female'=>Female));
$reg_form->addElement($icq_text);

the option is now displayed in register.php ..

but when i try to register a new user...the option selected (Male/female) is not save to database

what do i need to put in register.php ?

help
I Love Xoops

5
Alex_Grey
Re: dropdown menu in register.php
  • 2007/11/22 19:00

  • Alex_Grey

  • Just popping in

  • Posts: 43

  • Since: 2007/6/16


are you using.
$user_icq = isset($_POST['user_icq ']) ? $myts->stripSlashesGPC($_POST['user_icq ']) : '';


Also, are you setting the variable in the object.
$newuser->setVar('user_icq ',$user_icq,true);
“There is nothing impossible to him who will try.” ~Alex The Great~
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

6
phppp
Re: dropdown menu in register.php
  • 2007/11/23 1:18

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


Your data type is not compliant. Try

$icq_text = new XoopsFormSelect("Sex", 'user_icq', $user_icq);
$icq_text->addOptionArray(array(1 => "Male", 0 => "Female"));
$reg_form->addElement($icq_text);

7
noo-b
Re: dropdown menu in register.php
  • 2007/11/24 1:11

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


I finally got it working in my site..

Thanks to all who had helped me...

i really hope the XOOPS team to consider to include basic info like sex, age, birthday in XOOPS next version

as i said previously in an another thread the reason i don't want to use profile module available is because i just need one extra field (sex)...that's all..

any members that would like to do the same .......

here's how i did it in XOOPS 2.0171
-------------------------------------

** Change user_icq to sex drop down menu and include it
as a required field in registration from

** 4 files need to be edit - register.php, edituser.php, include/registerform.php & modules/system/templates/system_userinfo.html

First Step......


1. in include/registerform.php

add this
$icq_text = new XoopsFormSelect("Sex"'user_icq'$user_icq);
$icq_text->addOptionArray(array(1=>"Male"'0' =>"Female"));
$reg_form->addElement($icq_texttrue);


after

$reg_form->addElement(new XoopsFormText(_US_WEBSITE"url"25255$myts->htmlSpecialChars($url)));


2. in register.php

add this
$user_icq = (isset($_POST['user_icq']) && intval($_POST['user_icq'])) ? 0;


after

$url = isset($_POST['url']) ? trim($myts->stripSlashesGPC($_POST['url'])) : '';


add this
<input type='hidden' name='user_icq' value='".$user_icq."' />


after
<input type='hidden' name='user_mailok' value='".$user_mailok."' />



add this
$newuser->setVar('user_icq'$user_icqtrue);


after
if ($url != '') {
            
$newuser->setVar('url'formatURL($url), true);
        }


3. in edituser.php


find

$icq_text = new XoopsFormText(_US_ICQ'user_icq'1515$xoopsUser->getVar('user_icq''E'));



replace with

$icq_text = new XoopsFormSelect("Sex"'user_icq'$xoopsUser->getVar('user_icq'));
$icq_text->addOptionArray(array(1=>"Male"=>"Female"));



4. in modules/system/templates/system_userinfo.html

find this
<tr valign="top">
          <
td class="head"><{$lang_icq}>td>
          <
td class="odd"><{$user_icq}>td>
        tr>


and replace with

<tr valign="top">
          <
td class="head">Sextd>
          <
td class="odd"><{if $user_icq == "1"}>Male<{else}>Female<{/if}>td>
    tr>



Finish...clear templates_c/update system

there are maybe incorrect format of code used here so if anyone of you spotted a mistake please help me to correct it

thanks once again for those who had helped me..i appreciate it a lot
I Love Xoops

8
thooq
Re: dropdown menu in register.php
  • 2007/11/24 7:53

  • thooq

  • Just popping in

  • Posts: 9

  • Since: 2007/11/24


Hi

How amendment File Director for the Liberation of member?

thanks

9
sarahmx
Re: dropdown menu in register.php
  • 2008/7/24 2:29

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


hello may i know what to change if I want 3 option

> Male, Female, Private


thank you

Login

Who's Online

330 user(s) are online (275 user(s) are browsing Support Forums)


Members: 0


Guests: 330


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits