Reputation: 161
I have 2 php files and I want to link the two files by clicking a button .. so if I click a button in the first php file it should transfer my to the second php file ..
1st php file and here I want to click s & P Database button :
<html>
<body>
<h1> My System </h1>
<form action="">
<input type="button" value="S & P Database ">
<input type="button" value="Generate Report ">
</form>
</body>
</html>
2nd php file that I should have it when the button is clicked :
<html>
<body>
<form action="">
<h4><b>Please choose one of the following options below : </b> </h4>
<input type="radio" name="option" value="search" /> Search<br/>
<input type="radio" name="option" value="open database" /> Open Database<br/>
<input type="radio" name="option" value="administrative page "/> Administrative Page <br/>
</form>
// This button doesn't appear in the web page =( .. dunno why
<form action="">
<input type="button" value="Choose ">
</form>
</body>
</html>
Upvotes: 0
Views: 7999
Reputation: 7233
simple Put
method="post" or method="Get"
and in action type the name of 2nd file which in your case will be
action="2ndfile.php(what ever its name is)"
also in cahnage your button to submit
keep in mind that this action script is for your 1st file.
Upvotes: 0
Reputation: 2693
There are several ways to do this:
2 forms submitting to different locations
<html>
<body>
<h1> My System </h1>
<form action="page2.php" method="get">
<input type="button" name="pressed" value="S & P Database ">
</form>
<form action="page3.php" method="get">
<input type="button" name="pressed" value="Generate Report ">
</form>
</body>
</html>
2 links to different locations
<html>
<body>
<h1> My System </h1>
<a href="page2.php?pressed=sp">S & P Database</a>
<a href="page3.php?pressed=report">Generate Report</a>
</body>
</html>
1 form with name and values of buttons. But your script (page2.php) will need to check the value of $_GET['pressed'] too
<html>
<body>
<h1> My System </h1>
<form action="page2.php" method="get">
<input type="button" name="pressed" value="S & P Database ">
<input type="button" name="pressed" value="Generate Report ">
</form>
</body>
</html>
BUT dont forget to urldecode($_GET['pressed'])) as the values will be encoded.
Upvotes: 0
Reputation: 2242
You need to add link to php nahdler in action attribute
so it will be <form action="http://www.website.com/1.php">
Input type should be "image" or "submit", button will not submit your form.
You can also submit form by JS, but i will not describe how to do that here.
Use right document structure and doctype: http://www.rantiev.com/doctypes/ Check your code with validator: http://validator.w3.org/#validate_by_input When some elements dissapear it can be that HTML have errors.
Upvotes: 0
Reputation: 38426
If I understand correctly, you want to redirect the user to the second page when the button on the first page is clicked.
To simply redirect the user, you can use the button's onclick
:
<input type="button" value="S & P Database" onclick="window.location.href='page2.php'" />
Upvotes: 2
Reputation: 7596
<input type="button" onClick="window.location='/2nd.php'" value="S & P Database ">
This will redirect you to /2nd.php
Upvotes: 0