Current location: Hot Scripts Forums » Programming Languages » PHP » php passing value


php passing value

Reply
  #1 (permalink)  
Old 07-07-09, 05:26 AM
conmen80 conmen80 is offline
Newbie Coder
 
Join Date: May 2009
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Question php passing value

Hi all, maybe it was simple to accomplish but i really spent lots of time to code this without any value return...

How can i pass the input text 'term' value assign to onclick event like below?

Code:
<b>Enter Text:</b><br>
<input name='term' type='text' class='input' size='18'>
<input type='button' value='Go' onclick="samepage.php?q=<?php echo $term ?>" />
My form is using post method (some reason i can't use get method), i want to get the textfield value to perform a very simple search query on similar page...

Please help and thanks!!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-07-09, 06:01 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Any why exactly doesn't GET work? Sounds like the most appropriate solution here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-07-09, 07:14 AM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Yes use GET or POST

Like this:

<form action="my_phpscript.php" method="get">
<input type="text" name="The_Varable" size="18">
<input type ="submit" value="click here">
</form>

then in the script

$The_Varable=$_GET['The_Varable'];
echo $The_Varable;

GET will pass the data in the URL
POST will not
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-08-09, 01:36 AM
conmen80 conmen80 is offline
Newbie Coder
 
Join Date: May 2009
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
I must using POST method in the form, i could grab the text field value using javascript but there is no way to assigned it into php variable, i must use the value to perform sql query to gain some purpose...

Thx for replying!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-08-09, 02:33 AM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
You can use GET or POST either is the same, get just appends the variable string the the URL post does not. There are many times that I use GET but generally not for a form. POST is best for a form.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
how to use onclick in php coolcoder HTML/XHTML/XML 2 05-31-06 01:40 PM
Help with php value passing david510 PHP 15 04-05-06 12:14 PM
Passing a PHP variable in Javascript??? todayscoffee JavaScript 2 01-08-05 10:45 AM
Passing a PHP variable in Javascript??? todayscoffee PHP 2 01-04-05 02:56 PM


All times are GMT -5. The time now is 12:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.