Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: quick question

  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    21
    Thanks
    5
    Thanked 0 Times in 0 Posts

    quick question

    There are two buttons. One has an id=field_photo which needs to stay so that it can connect to the database properly.
    The other has an id=photo which the app requires to use properly.
    Is there somewhere that I can add something to make photo a pseudonym of field_photo so that one button only can be used?


    Code:
    <dt><label for="field_photo">{lang:"register","select_picture"} <!-- IF settings.require_registration_photo --><i>*</i><!-- ENDIF --></label></dt>
    <dd><input id="field_photo" type="file" name="photo" value="" class="text" /></dd>
    <p></p>
    <p>If on iPhone use button below</p>
    <dt><label for="image">Upload Image:</label></dt>
    <dd><input type="file" name="photo" id="photo"/></dd>

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    You can't really create a pseudonym, but you might be able to detect if it is an iPhone and hide that button, otherwise hide the other one.

    Code:
    // JavaScript - client-side
    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
    PHP Code:
    // PHP - server-side
    if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')) 
    This way both buttons would still be present to post data, but only one would be displayed to the user.

    BTW I don't know why this code I found uses match() and strstr() when they could use indexOf and strpos respectively.

    BTWW The same code would work for an iPad, iPuddle, iPoodle, etc..
    Last edited by AndrewGSW; 08-05-2012 at 12:59 AM.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    mikeisflux (08-05-2012)

  • #3
    New Coder
    Join Date
    Aug 2012
    Posts
    21
    Thanks
    5
    Thanked 0 Times in 0 Posts
    that's an awesome piece of coding however it still doesn't fix my database issue. In order for it to post to the database i need the id set to "field_photo" but the app requires id to be "photo" going through and changing this in the database and all the code would be way to extensive.

    Thanks all the same though.

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Not sure if I fully follow, but if the the same file needs to be posted as both 'field_photo' and 'photo' then I don't know if that is possible - particularly client-side.

    But 'field_photo' is the id, not the name, so this detail isn't posted anyway.. . At least, not without the intervention of some JS.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • Users who have thanked AndrewGSW for this post:

    mikeisflux (08-05-2012)

  • #5
    New Coder
    Join Date
    Aug 2012
    Posts
    21
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by AndrewGSW View Post
    Not sure if I fully follow, but if the the same file needs to be posted as both 'field_photo' and 'photo' then I don't know if that is possible - particularly client-side.

    But 'field_photo' is the id, not the name, so this detail isn't posted anyway.. . At least, not without the intervention of some JS.
    You just gave me an idea. I think that the call in the javascript code is now fixed so I can use just that one button.

    Code:
    <?php
    function checkMobileSafari() {
        if( preg_match( '/(iPod|iPhone|iPad)/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
            return true;
        } else {
            return false;
        }
    }
    ?>
    <?php
     if( checkMobileSafari() ) {
     
     echo  '<div class="info">It\'s Mobile Safari.</div>';
     
     echo '<script type="text/javascript" language="JavaScript" src="/js/prototype.js"></script>
            <script type="text/javascript" language="JavaScript" src="/js/picup.js"></script>';
     
    }
    ?>
    <script type="text/javascript"> 
    var currentParams = {}
     
     
    document.observe('dom:loaded', function(){
     
      $(document.body).addClassName('iphone');
     
    	// We'll check the hash when the page loads in-case it was opened in a new page
    	// due to memory constraints
        Picup.checkHash();	
     
       // Set some starter params	
       currentParams = {
    	'callbackURL' 		: escape('http://www.datethebasin.com/index.php?m=account_register'),				
    	'referrername' 		: escape('App Name'),
    	'referrerfavicon' 	: escape('http://www.datethebasin.com/favicon.ico'),
    	'purpose'               : escape('Select your photo for the our App.'),
    	'debug' 		: 'false',
    	'returnThumbnailDataURL': 'true',
    	'thumbnailSize'         : '80'
    	  };
     
        Picup.convertFileInput($('field_photo'), currentParams);
     
    	});
    </script>
    The Picup.convertFileInput($(' was set to photo, so i changed it to field_photo. So now it should work right provided the callbackURL is right?

    And here is the section of code that is relating to that for the upload button.

    Code:
    <!-- IF settings.enable_registration_photo -->
    <dt><label for="field_photo">{lang:"register","select_picture"} <!-- IF settings.require_registration_photo --><i>*</i><!-- ENDIF --></label></dt>
    <dd><input id="field_photo" type="file" name="photo" value="" class="text" /></dd>
    <!-- ENDIF -->
    Last edited by mikeisflux; 08-05-2012 at 02:00 AM.


  •  

    Tags for this Thread

    Posting Permissions

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