Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 07-17-2003, 04:29 PM
  #1
smnhicks
Aspirant (Level 2)
 
Join Date: Jul 2003
Posts: 20
iTrader: (0)
smnhicks is on a distinguished road
Passing Variables to a PHP script

I'm creating an input screen using HTML, PHP and MySQL. The page consists of a series of input fields and a submit button at the bottom to add the record to the database (nothing unusual so far).

Half-way down the form I have a link to another PHP script and I want to pass some of the varaiables which have been entered further up the form to this second PHP script.

The problem I seem to be having is that because the input fields have not been submitted at this point then the variables passed are the values from the record which was last added to the database.

Is it possible to pass variables that currently sit on the input fields to the second script?

Below is an example of the PHP code I am using for the link:

<? echo "<a href = 'calculator.php?currency=".$currency["CurrencyID"]."' TARGET = '_blank'>Price Calculator</A></td>" ?>

Further up the script:
<?
include("misc.php");
@ $db = mysql_pconnect($host,$user,$password);
mysql_select_db($database);
$currency_rs = mysql_query("select CurrencyID, CurrencyName, CurrencySymbol from travel_currency");
for ($h = 0; $h < mysql_num_rows($currency_rs); $h++) {
$currency = mysql_fetch_array($currency_rs);
echo "<option value='".$currency["CurrencyID"]."'>".$currency["CurrencyName"]." (".$currency["CurrencySymbol"].")</option>"; }
?>

Thanks for your help.

Simomn
smnhicks is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-17-2003, 06:02 PM
  #2
torrent
Super Deity (Level 18)
 
torrent's Avatar
 
Join Date: Dec 2001
Location: UK
Posts: 2,419
iTrader: (0)
torrent is on a distinguished road
Please read the posting rules before posting. All PHP posts go in the PHP forum.

The short answer to your question is "no". Javascript cannot pass values to PHP. You can pass values the other way (i.e. from PHP to Javascript) but not the way you want to without reloading the page. PHP has no knowledge of the HTML and is not event driven by Javascript methods, therefore it does not know you have entered values in those form fields. When you submit a form the values are passed back into the page (or to another page) in the http header.
torrent is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 02:25 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.