Jump to content


Photo

Show/Hide HTML form submit button in PHP


  • Please log in to reply
3 replies to this topic

#1 j3rmain3

j3rmain3
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 22 September 2006 - 10:11 AM

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.

html
coding for button -> <input type="submit" value="Button" name="button">

php
<?
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;

}
?>

Any help would be much appreciated.

J3rmain3





#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 22 September 2006 - 10:59 AM

Place this if statment in the bottom of your form and echo the submit button

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

#3 radalin

radalin
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 22 September 2006 - 11:47 AM

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.
Roy Simkes
Yet Another Parkyeri Developer

#4 j3rmain3

j3rmain3
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 22 September 2006 - 01:34 PM

Thanks a lot. Got it sorted out.

j3rmain3




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users