1
jilong
how to auto insert age in profile?
  • 2007/8/10 6:47

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


I had modify a bit in edituser.php to let user to enter DOB and AGE. But for make sure get the correct age, can we make the field be auto fill in?

now i only able to make it show the error alert the age are not match.

in
if ($op == 'saveuser') {


i add this code:

$age '';        
if (!empty(
$_POST['age'])) {
$age $myts->stripSlashesGPC(trim($_POST['age']));
}
$birth explode("-"$dob);
$diff date("Y") - $birth[0];    
        
if (
$age == '' || $age != $diff) {
$errors[] = _US_NEEDAGE;
}


But if the age can be auto fill in will be excellent. Hope some one can help me out on this. Thanks



2
jilong
how to autofill the age?
  • 2007/7/20 8:04

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


I try hack on edituser.php to make the age field be autofill in when after keyin the year of birth. i think i almost there but just can't get the 'year of birth' value,

1. I have replicate the formtext.php change it to formyear.php
Here is the code i change on my formyear.php:

Class and Function already change to 'XoopsFormYear' and
function render(){
    
$year date("Y");
    
$year2 "1980";
    
$year3 $year-$year2;
    
        return 
"<input type='text' name='".$this->getName()."' id='".$this->getName()."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".$year3."'".$this->getExtra()." />";
    }


2. Add 'include_once XOOPS_ROOT_PATH."/class/xoopsform/formyear.php";' into xoopsformloader.php

3. On edituser.php i add in this code:

$year_text = new XoopsFormText(_US_YEAR'year'44$xoopsUser->getVar('year''E'));

$age_text = new XoopsFormYear(_US_AGE'age'44$xoopsUser->getVar('age''E'));


I set the $year2 =1998 and the result i get is 27. ^^
But how can i replace the 1998 to the year value i had enter?

you guy have any ideal to do this?



3
jilong
Re: check field length function
  • 2007/7/19 9:17

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


OK, finally i solve it mysalve, and like to share out

if (!post || !preg_match("/^d{5}$/i",$post)){
        return 
false;
    }



4
jilong
Re: check field length function
  • 2007/7/19 7:58

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


Is there any ideal i can refer to?



5
jilong
check field length function
  • 2007/7/18 8:56

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


I had do some hack on edituser.php and function.php to do a validation for some fields. like Full Name field will only allow to enter alphabet and phone number only allow numbering. this two function is working fine with the code below.

function checkname($name)
{
    if (!
$name || !preg_match("/^[a-z @]+$/i",$name)){
        return 
false;
    }
    return 
$name;
}

function 
checkphone($tel_hp)
{
    if (!
$tel_hp || !preg_match("/^[0-9-]+$/i",$tel_hp)){
        return 
false;
    }
    return 
$tel_hp;
}


Now i would like to add in a field length validation for postcode,
Example: if the post code field enter more than 5 or less than 5 digit, the error message will show out.

But i have no ideal how to check the length, below is the code i try and actually not work. I hope to get any one have experience or ideal to do the length validation.

function checkpost($post)
{
for (
$i=0$i<strlen($post); $i++) {
    if (
$post.charAt(i) < 5){
        return 
false;
    }
}
    return 
$post;
}



6
jilong
How to change edituser.php display?
  • 2007/7/16 10:23

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


Because have problem to use 'XoopsFormTextDateSelect', https://xoops.org/modules/newbb/viewto ... p?topic_id=49073&forum=20

so i plan to use 3 select fields(year, month and day) to standardize the date display.

my problem is how to put 3 select field in 1 row?

Resized Image



7
jilong
Re: attach profiles details via email?
  • 2007/7/16 2:25

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


No, i mean like to add a 'mail' button at top / bottom on userinfo.php for admin only, when click on it will bring me to a screen like recommend friend to fill in the name and email to send the profile details.

the email i key-in will receive the profile details.



8
jilong
Re: Possible to have popup alert on edituser.php?
  • 2007/7/15 17:55

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


still no ideal to have popup alert, but finally i get the way to check name and phone number to show up error message

if ($name == '' || !checkname($name)) {

if ($tel_hp == '' || !checkphone($tel_hp)) {



9
jilong
attach profiles details via email?
  • 2007/7/14 14:24

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


I know this is quite stupid question, but just want to know is this prosible?



10
jilong
Re: Forms and time select
  • 2007/7/13 3:34

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


look like the XoopsFormDateTime not really work for my site. when i use this format the result will show as 'array'

When i try this XoopsFormTextDateSelect it show me the correct result '1980-3-11', but the problem is everytime when i click into edituser.php the date field will change back 1970-1-1.

Resized Image

is that any other file i need to make a change?




TopTop
(1) 2 3 4 ... 6 »



Login

Username:
Password:

Lost Password? Register now!

Who's Online

64 user(s) are online (38 user(s) are browsing Support Forums)


Members: 0


Guests: 64


more...

Donat-O-Meter

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

Latest GitHub Commits