Jump to content

Archived

This topic is now archived and is closed to further replies.

j3rmain3

Show/Hide HTML form submit button in PHP

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



Share this post


Link to post
Share on other sites
Place this if statment in the bottom of your form and echo the submit button

if ($ip ==ipAddress)
{
ie echo '<input type="submit"  .................
}

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.