Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Extra Profile Fields Not Saving

  1. #1
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    35
    Thanked 38 Times in 26 Posts

    Default Extra Profile Fields Not Saving

    I've attempted to add extra profile fields following the tutorial found here.http://hotarucms.org/showthread.php?...profile+fields


    Everything works fine, expect that when i click save the inputted web address doesn't actually save.

  2. #2
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    35
    Thanked 38 Times in 26 Posts

    Default

    Okay I got it to save by changing

    $profile['website'] = $h->cage->post->testUri('website');

    to

    $profile['website'] = $h->cage->post->getHtmLawed('website');

    Is this the right way of doing this?

  3. #3
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    if it doesn't save it's probably not a valid uri and the function testUri('website') will return false instead of the uri.
    to save any type of input you can use getRaw('website');

    getHtmLawed('website'); is used for cleaning up html code. it might work but i dont think its the way to go.
    Last edited by ties; 03-05-2010 at 01:14 AM.

  4. #4
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,859
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    testUri needs a full url with http:// on the front. As ties, said, if it doesn't work then it's not parsing as a valid url. getHtmLawed is the best alternative because it sanitizes the data.

    htmLawed:
    use to filter, secure & sanitize HTML in blog comments or forum posts, generate XML-compatible feed items from web-page excerpts, convert HTML to XHTML, pretty-print HTML, scrape web-pages, reduce spam, remove XSS code, etc.

  5. #5
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    Ok, but the demo @ http://www.bioinformatics.org/phplab...ties/htmLawed/ didn't do much for a string without the http://
    so im confused...

  6. #6
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    i'd do this if you really want the http://
    HTML Code:
    <tr><td>Website: </td><td>http://<input type="text" name="website" value="<?php echo $profile['website']; ?>"></td></tr>
    then (because some ppl just don't get it):
    Code:
    $profile['website'] = 'http://' . preg_replace('/^(http:\/\/)/', '', trim($h->cage->post->getRaw('website')));
    But maybe im just stubborn...
    Last edited by ties; 03-05-2010 at 01:52 AM.

  7. #7
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,859
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    Sorry ties, but my advice is still: Never use getRaw.

    This from Coppermine Gallery, another script that uses Inspekt:
    Care should be taken to as far as possible not use the getRaw() method - if it is used then please comment profusely as to why it is safe to use getRaw in the given circumstances (e.g.: the same value was tested against a regex before fetching or the value is sanitized immediately after getting). If there case where getRaw() cannot be avoided but is still unsafe please comment on possible solutions. Once again - the final aim is to NOT use getRaw() at all.
    A hacker could register for your site, input some malicious code in the profile website field and who knows what might happen?

  8. #8
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    that sound like a good argument
    its far more complicated than i thought...
    maybe this is a solution, after doing som research:
    Code:
    $url = 'example.com';
    if( filter_var($url, FILTER_VALIDATE_URL) ) echo $url;
    else if(filter_var('http://'.$url, FILTER_VALIDATE_URL)) echo 'http://'.$url;
    where url can be your sanitezed data, for the (good) sake of safety
    Last edited by ties; 03-05-2010 at 02:40 PM.

  9. #9
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    35
    Thanked 38 Times in 26 Posts

    Default

    I'm trying to add a drop-down list as one of the extra profile fields, I'm having a little bit of trouble getting this field to save, I'm pretty sure it has sometime to do with select name code

    Here's what I have in the edit_profile.php:

    Code:
    $profile['fname'] = $h->cage->post->getHtmLawed('fname');
    	$profile['lname'] = $h->cage->post->getHtmLawed('lname');
    	$profile['email'] = $h->cage->post->getHtmLawed('email');
    	$profile['type'] = $h->cage->post->getHtmLawed('type');
    	$profile['twitter'] = $h->cage->post->testUri('twitter');
    	$profile['website'] = $h->cage->post->testUri('website');
    	$profile['bio'] = sanitize($h->cage->post->getHtmLawed('bio'), 'all');
    Code:
     <tr><td>First Name: </td><td><input name="fname" type="text" value="<?php echo $profile['fname']; ?>" size="35"></td></tr> 
        <tr><td>Last Name: </td><td><input name="lname" type="text" value="<?php echo $profile['lname']; ?>" size="35"></td></tr>
        <tr><td>E-mail: </td><td><input name="email" type="text" value="<?php echo $profile['email']; ?>" size="35"></td></tr>  
        <tr><td>Twitter: </td><td><input name="twitter" type="text" value="<?php echo $profile['twitter']; ?>" size="35"></td></tr>
         tr><td>Website: </td><td><input name="website" type="text" value="<?php echo $profile['website']; ?>" size="35"></td></tr>
        <tr><td>About Me: </td><td><textarea cols=35 rows=3 name='bio'><?php echo $profile['bio']; ?></textarea></td></tr>
       <tr><td>Profile Type: </td><td> <select name=""><option value="Player">Player</option><option value="Coach">Coach</option><?php echo $profile['type']; ?> </select> </td></tr>
    And here is what i have in the profile.php file

    Code:
    <div id="profile_bio">
    
    <table> 
        <tr><td>Full Name: </td><td><?php echo $profile['fname']; ?> <?php echo $profile['lname']; ?></td></tr> 
        <tr><td>E-mail: </td><td><?php echo $profile['email']; ?></td></tr>
        <tr><td>Twitter: </td><td><a href="<?php echo $profile['twitter']; ?>"> <?php echo $profile['twitter']; ?></a></td></tr> 
        <tr><td>Website: </td><td><a href="<?php echo $profile['website']; ?>"> <?php echo $profile['website']; ?></a></td></tr>
        <tr><td>Type: </td><td><?php echo $profile['type']; ?></td></tr>
        <tr><td>About Me: </td><td><?php echo $profile['bio']; ?></td></tr>
    </table>
        	
    </div>
    Last edited by angolanmade; 03-08-2010 at 03:23 AM.

  10. #10
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    378
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    Code:
    <select name="type">
    <?php
    $profile_types = array("Player","Coach");
    foreach($profile_types as $profile_type) {
        if( $profile_type == $profile['type']) echo "<option value=\"$profile_type\" selected="selected">$profile_type</option>";
        else echo "<option value=\"$profile_type\" >$profile_type</option>";
    }
    ?>
    </select>
    Does this help?

    Edited: made a typo
    Edited 2: if you want to add profile type you can easily increase the array like this
    Code:
    profile_types = array("Player","Coach","Supporter","Referee","Another Type"); // etc etc etc
    Last edited by ties; 03-08-2010 at 03:19 AM.
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Docs] Adding Extra Profile Fields
    By Nick in forum Design and Layout
    Replies: 1
    Last Post: 03-15-2010, 03:00 PM
  2. [Docs] Adding Extra Post Information
    By Nick in forum Developing Plugins
    Replies: 0
    Last Post: 01-11-2010, 10:56 AM
  3. [Done] Profile page
    By runnertalk in forum Plugin Suggestion Box
    Replies: 5
    Last Post: 10-08-2009, 03:46 AM
  4. Saving different languages to the database
    By Nick in forum How-To and Troubleshooting
    Replies: 0
    Last Post: 07-17-2009, 05:41 PM
  5. [Docs] Extra ezSQL Functions
    By Nick in forum Developing Plugins
    Replies: 0
    Last Post: 07-13-2009, 05:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •