Jump to content

Button to execute


lljr

Recommended Posts

A button is clientside, PHP is a serverside language. You'd need to use a form like this..

 

<form action="whatever.php" method="post">

<input type="button" value="click me to calculate!"/>

</form

 

And it'll POST and inputs etc. to whatever.php. If you use a text input for example like you'd see in normal forms.. if an input was named 'name="ID" ' you could see it in PHP as.. $_POST['ID']..

 

Edit: You may want to use JS to insert a random number into the box. You can do buttons like this..

 

<button onClick="document.getelementbyID('rand1').value = 4">Button</button>

Link to comment
https://forums.phpfreaks.com/topic/170546-button-to-execute/#findComment-899610
Share on other sites

You mean like <input type="image" name="submit" > ???

 

When an image is clicked it sends the XY coordinates of the screen position that the mouse clicked.

 

To execute code with an image input you have to use


if ( isSet($_POST['submit_x']) )
{
   //code
}
//or 
if ( isSet($_POST['submit_y']) )
{
   //code
}

Link to comment
https://forums.phpfreaks.com/topic/170546-button-to-execute/#findComment-899612
Share on other sites

Archived

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

×
×
  • 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.