Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 22-05-2008, 10:31 PM   #1 (permalink)
In The Zone
 
bukaida's Avatar
 
Join Date: Jul 2005
Location: KOLKATA
Posts: 267
Default pass a text information to a php page using link


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.
__________________
Desktop: P-IV 2.4GHz, 512MB DDR, 865GBF Mother Board,
G-Force 5200FX, 17" Samsung flat, WinXp with SP2,
Kaspersky Internet Security 2009.
Laptop:LENOVO 3000 C100 D7 lappy with 2GB DDR2.
bukaida is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 22-05-2008, 10:38 PM   #2 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: pass a text information to a php page using link

Sorry but I am not sure what you exactly want:

May be you want to try this out:
Code:
html form code goes here
PHP Code:
<?php
if(isset($_POST["id"]))
{
include(
$id."php");//must validate the file name to prevent remote file inclusion attack.

//or


//fetch data from database
}
?>
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 23-05-2008, 05:58 AM   #3 (permalink)
MMO Addict
 
amitava82's Avatar
 
Join Date: Jul 2004
Location: Bangalore
Posts: 1,474
Default Re: pass a text information to a php page using link

AFAIK, without javascript its not possible. Here is how i'd do it:

1. Your html page:
Code:
<html> 
<head><title>Display by id</title> 
<script language="Javascript">
function button1()
{
    document.Form1.action = "search_prev.php";
    document.Form1.submit();
    return true;
}

function button2()
{
    document.Form1.action = "search_by_id.php";
    document.Form1.submit();
    return true;
}

function button3()
{
    document.Form1.action = "search_next.php";
	document.Form1.submit();
    return true;
}
</script>
</head> 
<body> 

<table align="center"> 
<form method="post" name="Form1" id="Form1"> 
<tr><td><b>Enter the Book id:</b></td> 
 <td><input type="text" name="id" size="10"></td></tr> 
  
 <tr>
 <td><input type="image" name="search_prev" src="images/prev.JPG" width="71" height="34" onclick="return button1()"></td> 
 <td><input type="image" name="search_by_id" src="images/Go.JPG" width="71" height="34" onclick="return button2()"></td> 
 <td><input type="image" name="search_next" src="images/next.JPG" width="71" height="34" onclick="return button3()"></td> 
 </tr>  
 </form> 
 </table> 
</body> 
</html>
2. Your php page:
PHP Code:
<?php
if (isset($_POST['id'])) {
$value $_POST['id'];
}
?>
Now the form value will be stored in $value and u can use it anytime you want. Say, you can echo it out:
PHP Code:
echo $value
You should also take security measures before using he value. Such as, escape sql special character using function mysql_real_escape_string, stripe html tags using strip_tags in order to prevent cross site scripting attack.
__________________
Steam Profile || Personal Page
Warp drive active. Approaching stargate.

Last edited by amitava82; 23-05-2008 at 06:06 AM.
amitava82 is offline  
Old 27-05-2008, 11:35 AM   #4 (permalink)
In The Zone
 
bukaida's Avatar
 
Join Date: Jul 2005
Location: KOLKATA
Posts: 267
Default Re: pass a text information to a php page using link

Is there any way to avoid the button? I mean by using the GET method with hyperlink because I want to have the coloured picture of Prev, Next etc to be retained..Security is not a major concern here.
__________________
Desktop: P-IV 2.4GHz, 512MB DDR, 865GBF Mother Board,
G-Force 5200FX, 17" Samsung flat, WinXp with SP2,
Kaspersky Internet Security 2009.
Laptop:LENOVO 3000 C100 D7 lappy with 2GB DDR2.
bukaida is offline  
Old 27-05-2008, 11:55 AM   #5 (permalink)
MMO Addict
 
amitava82's Avatar
 
Join Date: Jul 2004
Location: Bangalore
Posts: 1,474
Default Re: pass a text information to a php page using link

Where am I using any buttons? 'button' are just function names.. Did u even try the code?
__________________
Steam Profile || Personal Page
Warp drive active. Approaching stargate.
amitava82 is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give me some link to some URL which has basic computer hardware information Count Dracula Hardware Q&A 1 31-10-2007 01:03 AM
How to convet scanned page. into text format Kaushal Hiwarkar QnA (read only) 3 22-10-2007 03:23 PM
Unix text to notepad readable text? How? adithyagenius QnA (read only) 4 09-06-2007 07:27 PM
printed page back to text file...? Saharika QnA (read only) 2 13-11-2005 06:16 PM
Changing page link name ax3 QnA (read only) 2 06-05-2005 03:11 PM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:02 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2