Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-05-2012, 12:35 AM   PM User | #1
mikeisflux
New Coder

 
Join Date: Aug 2012
Posts: 21
Thanks: 5
Thanked 0 Times in 0 Posts
mikeisflux is an unknown quantity at this point
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>
mikeisflux is offline   Reply With Quote
Old 08-05-2012, 12:50 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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..
__________________
"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

Last edited by AndrewGSW; 08-05-2012 at 12:59 AM..
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
mikeisflux (08-05-2012)
Old 08-05-2012, 01:16 AM   PM User | #3
mikeisflux
New Coder

 
Join Date: Aug 2012
Posts: 21
Thanks: 5
Thanked 0 Times in 0 Posts
mikeisflux is an unknown quantity at this point
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.
mikeisflux is offline   Reply With Quote
Old 08-05-2012, 01:33 AM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
mikeisflux (08-05-2012)
Old 08-05-2012, 01:49 AM   PM User | #5
mikeisflux
New Coder

 
Join Date: Aug 2012
Posts: 21
Thanks: 5
Thanked 0 Times in 0 Posts
mikeisflux is an unknown quantity at this point
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..
mikeisflux is offline   Reply With Quote
Reply

Bookmarks

Tags
php, picup

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:29 PM.


Advertisement
Log in to turn off these ads.