Forum Moderators: coopster

Message Too Old, No Replies

access button in HTML file through PHP file

         

redweb

12:00 pm on Mar 10, 2006 (gmt 0)



Hi ,
I’m new to PHP and I’m working on a code and having a problem .
The problem is that I’m having an HTML file like this :

////////////////////////////////////


<p>some text</p> <form action="/project/myfile.php" method="post"> <input type="button" name="mybutton.1" value=" mybutton "><input type="text" name="aaa" /> </form>

<p> some text </p> <form action="/project/myfile.php" method="post"> <input type="button" name=" mybutton.2" value=" mybutton "><input type="text" name="aaa" /> </form>


//////////////////////////////////////
I want to open a new HTML file to the user when he clicks on any of these buttons .
I want to do this in the file named “myfile.php “ .
What should I write in the file “myfile.php “ to get access to each button and open a new page when the user clicks on it?
Is it correct to put " action="/project/myfile.php""?
Should I put include the HTML file in my PHP file?
I want also to remember which button the user clicks on .
Plz help me ..

inveni0

12:47 pm on Mar 10, 2006 (gmt 0)

10+ Year Member



Each button would probably need its own form. Each form would need a hidden feild. The value of this field would be what you would need to remember.

Once the button is clicked, the PHP file would get that form variable, since it is most likely the URL to redirect to, and use it (though you will loose the value if sending to HTML).

Anything you need to remember about the button click can also be added as a hidden field.

redweb

3:40 pm on Mar 10, 2006 (gmt 0)



Thankx for your replay inveni0

But I’m still facing a problem
This is the html file I have :


<HTML>
<HEAD>
<TITLE>A simple form</TITLE>
</HEAD>
<BODY>
<FORM method="POST" action="myfile.php">
<INPUT type="submit" name="mybutton" value="Click me!">
</FORM>
</BODY>
</HTML>

and this is the php file :

<HTML>
<HEAD>
<TITLE>php file</TITLE>
</HEAD>
<BODY>
<?
if(isset($_POST['mybutton'])) {
echo "this will appear when button is clicked\n";
} else {
echo "this will appear without clicking the button.\n";
}
?>
</BODY>
</HTML>

it doesn’t work . when I click on the button the file down load window will appear asking me to down load “myfile.php”.

I don’t know what is the problem?