Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run PHP File On Button Click

Tags:

html

php

button

I wonder whether someone could help me please.

I've been looking through this, and many other sites and tutorials to find out how to add a button to a form which opens a PHP file, in this case, a pop up form that allows a user to upload a file to a mySQL database.

In addition to the opening of the file, I'd like to carry over the 'id' field value from the main form to the pop 'File Upload' form.

From the research I've carried out there seems to be a number of ways to do this, but from a beginners perspective I'm not sure what is the best way to do this.

Could someone perhaps please advise on what is the best way to go about this.

Many thanks and kind regards

like image 501
IRHM Avatar asked Dec 18 '11 16:12

IRHM


1 Answers

To pass values between pages:

Main form:

<form action="myuploadform.php" method="get">
ID: <input type="text" name="id">
<input type="submit" value="Open Form">
</form>

The value of the ID text box will be accessible as $_GET['id'] in myuploadform.php.

Using GET parameters is the simplest way of passing values. Another way to pass in this GET value would be in the URL:

.../myuploadform.php?id=35 where the ID then becomes 35.

like image 55
Tim Avatar answered Oct 03 '22 12:10

Tim