j3rmain3 Posted September 22, 2006 Share Posted September 22, 2006 HiI am trying to make the submit button in an HTML form display or disappear depending on a users ip address.I was testing this out by placing the ip address into a variable and then doing an if..else statement to change some text which worked well.Then i tried to use similar coding to show and hide the button but..1)was unable to find a hide/show function in php (dont think there is one after looking in the forum)2)naming the button so its recognised as a a variable inside php when the page is first loaded.[size=6pt][b]html[/b][/size][code]coding for button -> <input type="submit" value="Button" name="button">[/code][size=6pt][b]php[/b][/size][code]<?coding to show/hide -> if($ip ==ipAddress){#this is where i have no idea what to add to show/hide button;} else {#this is where i have no idea what to add to show/hide button;}?>[/code]Any help would be much appreciated.J3rmain3 Link to comment https://forums.phpfreaks.com/topic/21647-showhide-html-form-submit-button-in-php/ Share on other sites More sharing options...
steveclondon Posted September 22, 2006 Share Posted September 22, 2006 Place this if statment in the bottom of your form and echo the submit button if ($ip ==ipAddress){ie echo '<input type="submit" .................} Link to comment https://forums.phpfreaks.com/topic/21647-showhide-html-form-submit-button-in-php/#findComment-96623 Share on other sites More sharing options...
radalin Posted September 22, 2006 Share Posted September 22, 2006 instead of hiding, try adding disabled on your submit button. Which will completely disable it. <input type="submit" value="Send" disabled />But it wont prevent someone to submit the form I think. With javascript injection something like javascript:void( document.myForm.submit(); ) should submit your form I think. But I'm not sure. Try it on your browser if it works or not if you put disable on the submit button or even if you hide it. Link to comment https://forums.phpfreaks.com/topic/21647-showhide-html-form-submit-button-in-php/#findComment-96645 Share on other sites More sharing options...
j3rmain3 Posted September 22, 2006 Author Share Posted September 22, 2006 Thanks a lot. Got it sorted out. j3rmain3 Link to comment https://forums.phpfreaks.com/topic/21647-showhide-html-form-submit-button-in-php/#findComment-96712 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.