Jump to content

Show/Hide HTML form submit button in PHP


j3rmain3

Recommended Posts

Hi

I 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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.