FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Submit information by anchor tag from textbox





bukaida
I want to pass a text information to a php page using link. The following code will display my intention.
Code:

<html>
<head><title>Display by id</title>
</head>
<body>
<form >
<table align="center">
<tr><td><b>Enter the Book id:</b></td>
 <td><input type="text" name="id" size="10"></td></tr>
 
 <tr><td><a href="search_prev.php"><img src="images/prev.JPG" alt="" width="90" height="34" border="0"></a></td>
 <td><a href="search_by_id.php"><img src="images/Go.JPG" alt="" width="71" height="34" border="0"></a></td>
 <td><a href="search_next.php"><img src="images/next.JPG" alt="" width="90" height="34" border="0"></a></td>
 </tr>
 </table>
</form>
</body>
</html>


There is a simple textbox. Below it there are three hyperlinks containing the image(like a button).
The idea is to go to three different php pages (one at a time, depending on the click) with the textbox value so that they can be used in those pages(by $_POST/GET/REQUEST or any other method).How to do that? Please help.
rvec
Best to use $_GET[] I think. You can use this as search.php:

Code:

<?php if (!isset($_GET['id'])) {
    $id = 1;
} else {
    $id = (int) $_GET['id'];
} ?>
<html>
<head><title>Display by id</title>
</head>
<body>
<form >
<table align="center">
<form action="search.php" method="get">
<tr><td><b>Enter the Book id:</b></td>
 <td><input type="text" name="id" size="10"></td></tr>
 
 <tr><td><a href="search.php?id=<?php echo $id - 1; ?>"><img src="images/prev.JPG" alt="" width="90" height="34" border="0"></a></td>
 <td><input type="submit" value="submit" /></td>
 <td><a href="search.php?id=<?php echo $id  + 1; ?>"><img src="images/next.JPG" alt="" width="90" height="34" border="0"></a></td>
 </tr>
 </table>
 </form>
</form>
</body>
</html>


I don't know how to make an image of that submit button, but maybe someone else knows.

If you want to use the id of the page somewhere else it would be best to use $id and not $_GET['id'] because you can be sure $id is set and is a number.
bukaida
Is there any way to avoid the submit button?
rvec
you could just leave it out and let users press enter
bukaida
ya thats a nice trick.Thank you.
Related topics
Tutorial: PHP Installed Modules Dynamic Reference Tool
Google Tests New Service
Need help with basic HTML
JavaScript Overlaps
Registration page, i really need some help!
HTML submit textbox functions etc.
Pet Stable!
[Guide] HTML and CSS
a cool script for a juicy image gallery
How to get members area on my website??!
Change background of a DIV (no JS)
Invalid XHTML - Please help.
Link Exchange With a website having PR.
Php $_POST
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.