post method
Moderator: General Moderators
post method
is it possible to $_POST/$_GET an input box value from inside a script decalred via a headers? ie
a.html b.php c.php
<form action='b.php' <script ... src='c.php' /script> $_POST[$name]
method='post'>
<input box
name ='pool'
value='true'
...submit
previously i had the contents of c.php as a function which was called in b.php but having reworked the code, i have been unable to reclaim the values in the html.
a.html b.php c.php
<form action='b.php' <script ... src='c.php' /script> $_POST[$name]
method='post'>
<input box
name ='pool'
value='true'
...submit
previously i had the contents of c.php as a function which was called in b.php but having reworked the code, i have been unable to reclaim the values in the html.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I am not exactly clear what you are trying to do, but perhaps echo() is what you are looking for:
Code: Select all
<?php
include 'c.php'
echo $_POST[$name];
?>(#10850)
feyd | Please use
but i still get empty values
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
i'm trying to get input values from a html page to a php/javascript script via a php script that calls the php/javascript script.
i figure i'd probably need to pass the values in the url that calls the script, so i added the following to the intermediary script:Code: Select all
$query_string = 'dj=' . urlencode($dj) . 'liveMusic=' . urlencode($liveMusic)
. 'kidsZone=' . urlencode($kidsZone) . 'lateLice=' . urlencode($lateLice)
. 'nsArea=' . urlencode($nsArea) . 'food=' . urlencode($food)
. 'garden=' . urlencode($garden) . 'skySport=' . urlencode($skySport)
. 'cocktail=' . urlencode($cocktail) . 'pool=' . urlencode($pool);
//third parameter outputs script to header
echo xhtmlheader('Create Pub Crawl', 'KEY', 'map_data2.php?'.htmlentities($query_string), 'mapFunctions.js');feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]sorry missed out a php tag in previous post
Code: Select all
$query_string = 'dj=' . urlencode($dj) . 'liveMusic=' . urlencode($liveMusic)
. 'kidsZone=' . urlencode($kidsZone) . 'lateLice=' . urlencode($lateLice)
. 'nsArea=' . urlencode($nsArea) . 'food=' . urlencode($food)
. 'garden=' . urlencode($garden) . 'skySport=' . urlencode($skySport)
. 'cocktail=' . urlencode($cocktail) . 'pool=' . urlencode($pool);
//third parameter outputs script to header
echo xhtmlheader('Create Pub Crawl', 'KEY', 'map_data2.php?'.htmlentities($query_string), 'mapFunctions.js');- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
OK, I am guessing that you want to output Javascript. If not you would use the PHP header() function and then you need to follow the HTTP spec for what you output.
Javascript is output just like you would output HTML, so put double quotes around it so your $query_string variable is expanded and make sure and double quotes are escaped (you seem to have only single quotes) and make sure the Javascript lines have semi-colons too:
Javascript is output just like you would output HTML, so put double quotes around it so your $query_string variable is expanded and make sure and double quotes are escaped (you seem to have only single quotes) and make sure the Javascript lines have semi-colons too:
Code: Select all
echo "xhtmlheader('Create Pub Crawl', 'KEY', 'map_data2.php?'.htmlentities($query_string), 'mapFunctions.js');";
Last edited by Christopher on Tue Nov 07, 2006 12:23 pm, edited 1 time in total.
(#10850)
xhtmlheader() is a php function of mine in the intermediary page. when its called, it passes parameters that are inputted into an html header.
Burrito, i've now added ampersand. thanks for that. but i'm still not getting the results i need. am i adding the third parameter incorrectly?
Burrito, i've now added ampersand. thanks for that. but i'm still not getting the results i need. am i adding the third parameter incorrectly?
Code: Select all
echo xhtmlheader('Create Pub Crawl', 'KEY', 'map_data2.php?'.htmlentities($query_string), 'mapFunctions.js'); //'map_data.php',What does it print? Please provide example output.garry27 wrote:Code: Select all
echo xhtmlheader('Create Pub Crawl', 'KEY', 'map_data2.php?'.htmlentities($query_string), 'mapFunctions.js'); //'map_data.php',
it prints:
the input values stem from checkboxes with a value of 'true'. obv if their unchecked when their submitted, they don't return anything.
Code: Select all
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
<head>
<link href='perfectpubcrawl.css' rel='stylesheet' type='text/css'/>
<SCRIPT language=JavaScript src= ' http://maps.google.com/maps?file=api&am ... xxxxxxxxx' ></SCRIPT>
<SCRIPT language=JavaScript src= ' map_data2.php?dj=&liveMusic=&kidsZone=true&lateLice=true&nsArea=true&food=&garden=&skySport=&cocktails=&pool= ' ></SCRIPT>
<SCRIPT language=JavaScript src= ' mapFunctions.js ' ></SCRIPT><meta http-equiv='Content-Type'
content='text/html;
charset=utf-8' />
<title>Create Pub Crawl</title>
</head>Yes, that's how it works, see http://www.w3.org/TR/html4/interact/for ... l-controlsgarry27 wrote:the input values stem from checkboxes with a value of 'true'. obv if their unchecked when their submitted, they don't return anything.
Your script can test the absence of a parameter via isset().
you should remove the leading blanks from your src attributes.
hi, thanks for the advice. i'm having problems now collecting the data sent to map_dat2.php (the php <script>).
i'm trying to use the following code to create a php stringvariable, $filter. this code worked before i moved it from a standard php page. as it is now, i can't can't output the values in $filter without it screwing the script.
outputing $filter to jscript like this messes the script up and doesn't display the alert box:
i'm trying to use the following code to create a php stringvariable, $filter. this code worked before i moved it from a standard php page. as it is now, i can't can't output the values in $filter without it screwing the script.
Code: Select all
$chkbox_arr = array ( 'dj', 'liveMusic', 'nsArea','food','skySport', 'cocktails'
,'pool', 'garden', 'lateLice', 'kidsZone' );
//filter out unchecked boxes
for ( $i = 0; $i <10; $i++ ) {
$element = $chkbox_arr[$i];
if ( !isset( $_GET[$element] ) ) {
unset( $chkbox_arr[$i] );
}
}
// re-sort index and count number of elements
sort ($chkbox_arr);
$result = count($chkbox_arr);
//add sql string to each element
for ( $i = 0; $i <$result; $i++ ) {
$chkbox_arr[$i]=' AND Amenities.'.$chkbox_arr[$i]."='y'";
}
// create string of all elements
$filter = implode(" ", $chkbox_arr );
/////// ...this will then be used to add to the mysql queryCode: Select all
print "alert('" .$filter ."');";and?
Code: Select all
echo "<pre>\nfilter: ", htmlentities($filter), "</pre>\n";