paulhook Posted February 10, 2010 Share Posted February 10, 2010 Hi, I am trying to limit the amount of photo's a user can upload the code I wrote for my html.php page doesn't work because it always displays a submit button. I would like it to display either a plain text message or a submit button. Disregard the fact that no values are being passed to my if test, my actual code is longer and passes the correct values so that the test works. <tr> <td colspan="2"><input type="submit" class="button" value="<?php if ( $images_total < "3" ) { echo "_UPLOAD_SUBMIT"; { else { echo "You have reached your upload limit"; } { } ?>" /></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/191637-limiting-user-uploads/ Share on other sites More sharing options...
Wolphie Posted February 10, 2010 Share Posted February 10, 2010 Well, first of all $images_total should be an integer, not a string. Adding the quotes make it a string so using the greater than or less than comparison operators won't work here. <tr> <td colspan="2"><input type="submit" class="button" value="<?php if ( $images_total < 3 ) { echo "_UPLOAD_SUBMIT"; { else { echo "You have reached your upload limit"; } { } ?>" /></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/191637-limiting-user-uploads/#findComment-1010163 Share on other sites More sharing options...
paulhook Posted February 10, 2010 Author Share Posted February 10, 2010 Thanks for the reply, the $images_total < 3 was more of a typo than a problem, my problem is that either test message is still a submit button, I have attached pics of both results. I would like to only display a submit button if the upload limit is not reached. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/191637-limiting-user-uploads/#findComment-1010176 Share on other sites More sharing options...
PFMaBiSmAd Posted February 10, 2010 Share Posted February 10, 2010 In order to output either the submit button or a message, the submit button code must be inside the conditional statement. Now it is not. Quote Link to comment https://forums.phpfreaks.com/topic/191637-limiting-user-uploads/#findComment-1010178 Share on other sites More sharing options...
paulhook Posted February 10, 2010 Author Share Posted February 10, 2010 PFMaBiSmAd THANKS SO MUCH!!! That was the problem, $SUB_BUTTON = '<input type="submit" class="button" value="SUBMIT" />'; if ( $num_of_images < 4 ) { echo $SUB_BUTTON;} else {echo "You have reached your upload limit"; } { } ?> Quote Link to comment https://forums.phpfreaks.com/topic/191637-limiting-user-uploads/#findComment-1010195 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.