How Does One Pass Array Variables Between URLs?
I would like to pass array variables between URLs but I don't know
how. I know its possible with sessions, but sessions can become
useless if cookies are disabled. I have unsuccessfully tried using
post and get methods.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Masking Variables In URLs
When I pass variables to a new page, my URL string becomes impossibly long. I'd like to hide the variables in the URL. How would I do that?
Methods To Pass Variables
I am trying to pass 8 variables from a search form to different pages and I am confuse whether to use: 1) session 2) cookie 3) passing variable through URL 4) Using hidden form field My page#1 is a search form and with 8 Select fields. After press Submit Button, page#2 shows all the search results. Some search would show up 100+ rows so I am using a script to break the result pages. Each display page would limit 20 records with links <<Previous 1 2 3.... Next>> at bottom. However only the first search result page would show up properly but rest of search result won't showup. I read a few threads on this forums and I wonder what is the best method to use in my case??? It seem passing variable through URL is inefficient in my case since there are 8 variables. With session or cookie, what happen if the user decide to do another search (page#1 search form) without closing browser will the session id renew itself. With hidden form field, since my Page#2 (result display page) is not using form, will it work.
Pass Get Variables Using PHP Header()
I got a form page with 'update' & 'cancel' buttons. When 'cancel' clicked, I want to be redirected to the index page on the right page number. URL of my edit page is like this: http://localhost/form.php?op=edit&id=1&cursor=2 In the form.php I got few lines of code to get that 'cursor' before doing redirection: $iCursor = $_GET["cursor"]; $url = 'index.php?cursor='.(int) $iCursor; if ($_POST["cancel"]) { header("Location: $url"); } The new URL is supposed to be: http://localhost/index.php?cursor=2 but it showed up like this: http://localhost/index.php?cursor=0 I've tried using sessions variables as well, but the value of the cursor's still 0. Do you guys know what happened?
How To Pass Variables To PHP Binary (CGI)?
My system use to run PHP as an Apache module. And I pass in variables like this: http://www.somesite.com/somefile.php?IDvar=1 Now my system runs PHP as a CGI. So I am running the same script like this: /usr/local/bin/php /somepath/somefile.php How do I pass in the variable IDvar and value 1?
Can't Pass Variables By URL On Localhost
I'm developping on localhost (127.0.0.1). When I try to pass parameters from one page to another using the standart way (URL), I just can't retrieve the values. In fact, the isset($varname) returns false. Code:
Pass Variables To Functions
In php i've found that I cant seem to access global variables from within a function. Is there a way to access variables in a function that are in the same scope that the function is??? Can you make a variable global or something? How does that all work in PHP, is there a doc somewhere to explain? Can I define a global within a function in php?
How Do I Pass Variables On A Location
i have a script which creates 2 variables which then does a redirect to a page which then uses a query using the two variables. But i was wondering how to get the code to pass across the page... Code:
Pass Variables Via Include Command?
I've been trying to put amend a variable to the end of an include statement, but each time I do this, the variable isn't passed. For example:
Pass The Variables In The Form Of Sessions
If I have something like this how can i pass the variables in the form of sessions to another page, where i Can calculate based on the products selected, very much like a shopping cart! PHP Code:
Pass Variables To Php Include File
I'm working on using an include file that is set up all good to go for an image gallery. The one thing I need to change though, is the path. My code is simple enough using the inculde PHP Code:
Pass Upload Page Variables
As I sure will become obvious with the asking of this question, I am new to programing.... I have copied and pasted my way to a successful file upload page and have built some rather ugly if elseif loops that read the file and extract the needed data from it. While the data is being parsed from the uploaded file a string variable is being built that holds some details of the process. All of this happens when the user clicks the upload button on the form. Now when all this code is finished running, I ASSUME the page reloads, because my string variable seems to be empty. So, my question is how do I keep this variable so that I can print it to the form when the process is finished?
Search - Pass Variables Or Self Post
I've created a database of documents that is searchable by a variety of fields. Currently I have a PHP page called search.php with a form to get the keywords from the user and it then passes this back to itself, runs a query and displays the results. Doing it this way the address for the search page and the results of the search is the same. This all works fine and I'm happy with it but I was wondering if it should be implemented differently where the keywords are used as a part of the address like with search engines with Google. I don't know what the advantages or disadvantages is for either method so I'm keen to hear what others think is the best method.
Getting The Server To Pass Variables And Not The Client Browser
I have a page on my site that has a form for people to include their name and e-mail that I need to send to another site to save to a database. The receiving/action page will then give a response depending on the point of failure or if the send and storage was successful. Seems simple enough, but I need to include a use an id and password with the information for the third party to accept the info. I can't include these as hidden form fields, as you could see them in the source. I can post the inputted variables to a second page and add the sensitive variables before using the header function in php to call up the third party site, but I can only use query string from there to pass the variables over, which will of course expose the details I was trying to hide. The info has to be passed, there's no db option. Other people have supposedly written functions that POST the info on from the second page so it's not part of the query string, which would be an acceptable solution, but I can't seem to figure out how to do that. The ideal would be for the php page to send the users info & the sensitive info to the server, wait for the response, interpret it and write to the page the result.
Hide GET Variables --> Pass Values Using Session
I have a php file which lists some records. On this list, the records can be sorted on different columns. currently the sort column and the direction of sorting is passed using GET values, this means the user clicks the column name (which is a link) so the new sort column and direction is passed to the script <a href="main.php?page=news&sortfield=title&sortorder=asc"> now my question is, if it's possible to hide those values, so they don't appear on the url, but sorting should work anyway. This means that 1. when user clicks on column, the new sort order has to be set 2. page has to be reloaded, so new sort order gets displayed. I'd like to do this using sessions, but I don't know how to update a session value, when clicking on a link wihtout using GET values...
How Do I Pass Constructor Variables To An Assembly Using DOTNET?
How can I pass a necessary parameter while instantiating an object from a .NET assembly using DOTNET in PHP 5? The sample code that came with the .NET assembly shows how to do this is with VB and C#: VB: Dim transaction As New Paymentech.Transaction(RequestType.CC_AUTHORIZE) C#: Paymentech.Transaction(Paymentech.RequestType.CC_AUTHORIZE); I've tried the following using PHP: $transaction = new DOTNET("ptDotNetSDK20","Paymentech.Transaction(CC_AUTHORIZE) ") and $transaction = new DOTNET("ptDotNetSDK20","Paymentech.Transaction(RequestType.CC_AUTHORIZE) ") and even $transaction = new DOTNET("ptDotNetSDK20","Paymentech.Transaction(Paymentech.RequestType.CC_AUTHORIZE) ") and each time get errors "Failed to instantiate .Net object". I've even tried enclosing the parameter in single quotes, with no improvement. If I leave out the parameter and just try: $transaction = new DOTNET("ptDotNetSDK20","Paymentech.Transaction") I am able to create the transaction, but am then told "Transaction Object is invalid" when I later try to use it, which makes sense since I didn't create it with the necessary parameter in the first place.
$_SESSION Requires Refresh To Pass Variables To (jp)graph File
I cannot figure out why my graphs will not accept $year variables defined by a form. The first time I send the form the $year variables passed to the graphs are the old $_SESSION versions but if I refresh the browser once on the output page, everthing is fine.
Preg_replace Call Funtion And Pass Variables Inside Class
I have wasted almost two days for this, but can't figure out whats wrong with it. I have class with functions. The problem is that when I have a preg_replace in a function, and it calls other function in that class, I can't pass my variables to that function. Weird thing is that, it works fine, if the function that I call is not in a class. The preg_replace is guite ugly, but it works =). Idea is to parse string where are some url-tags and convert them to a href links, with some addon features like: link-http-check and word-chopping so it ain't too long to mess up with strick layout. The function which has the preg_replace inside of it, PHP Code:
Pass A Querystring Through <a Href="mailto:xxxx .... Using PHP Variables
I'm trying to send a link with a querystring as the body of an email message. My HTML syntax looks something like this: <a href="mailto:xxx@yyy.com?Subject=<? print $subject ?>&Body=<? print urlencode($url) ?>">Send an Email</a> (I've had to URLENCODE the variables first, and it works. If I don't do so, then it doesn't work.) The problem occurs when it is time to display the encoded version. It automatically translates it into the appropriate URL in certain email clients (like OUTLOOK) but leaves it encoded in others (like Groupwise). Basically, I would like to be able to email a link in the body with querystring in such a way that it appears on ALL email clients. I've tried lots of things, but nothing seems to work.
Pass Array To Pop-up Window
How would I pass an array to a window I'm popping open? I read a little bit about session variables(I'll have to do some research) I'm thinking maybe that's somewhere to start.
How To Pass An Array From On Php Page To Another
i want to send an array from one age to another... i am not using a form....so cant use php-trace-vars.. i have variables...in an array and i want these array elements to be visible on next page too...without posting them..how is this possible.
Pass Array Into Select Query ?
I was wondering if it is possible to pass a php array into a mysql query rather than looping through each one eg: //the array $namesArray = array("Joe", "Jane", "Bob", "Mary", "Paul", "Eddie", "John"); //the sql SELECT id FROM users WHERE name='$namesArray'
Pass The Entire Array Through A Form.
Im working with an array in my php script and need to pass the entire array through a form. Here is the script. Take a look and tell me if you can see my mistake. I create a dynamic entry screen that has multiple values that I would like to update and want to place them all into an array to update them. At the mo no values are being posted at all. Code:
Pass An Array To A Quyery String
Assuming i had an array ($myarray) which holds maybe (1,2,3) how do i pass it in the query string so i get select hd from mytable where hd in (1,2,3).
How Can I Pass A Parameter Array From PHP To A Javascript Function
I have a Javascript function that validates an specific form. As parameters this function receives an array of elements to be checked. Depending on the form in cause, the array could have variable lenght. I don't know how can i pass a dynamic array on 'onsubmit' event form PHP code to a JavaScript function. I would like to do something like: <script> function Valid_Form(ElementsArray) { alert (ElementsArray[0].value); alert (ElementsArray[1].value); return (true); } </script> .... <?php ... echo "<form method='post' action='?oper=confirm' onSubmit='return Valid_Form(this.elements[0], this.elements[1])'>"; ... ?> But it don't work!
Function Inside A Class Function Dont Pass Variables...
Im using xajax class, and i just made a custom class called mantenimientos that use objects of this xajax class. Something like this: class mantenimiento { public $titulo; public $ajax_sRequestURL; function __construct($titulo,$ajax_url){ $this->titulo = $titulo; $this->ajax_sRequestURL = $ajax_url; } function exec_ajax(){ //Here i can use $this with no problem $xajax = new xajax($this->ajax_sRequestURL); $xajax->registerFunction("call_fun"); //I have to do this to have acces to the class itself when im inside a function global $mant ; $mant = $this; function call_fun(){ //next line give me access to the mantenimiento class properties. //I havent found other way of doing it. global $mant; $objResponse = new xajaxResponse(); $objResponse->addAlert('XAJAX CALLED:'.$mant->titulo); return $objResponse->getXML(); } $xajax->processRequests(); } My problem is that $mant->titulo lost it value when i im inside the funciton, but only when that value comes from other var. for example: if i do this: $mant = new mantenimiento('This is the title','index.php'); or $titulo = 'This is the title' $mant = new mantenimiento($titulo,'index.php'); When i execute the xajax_call_fun, it shows an alert box with the text "XAJAX CALLED:This is the title" but if i do something like this: $titulo = gettitulo_from_database(); or $titulo = $_POST['titulo']; The alert box show the mensaje with out the value of the $mant->titulo Im getting crazy with this....!
Creating Dir, Copy Files And Pass Variables To 2 Files
I need to create a folder on the server weekly named by the user. To this folder copy the contents of an /Original folder. Inside the new folder edit one of the files to insert a data with a XML path generated in another application, copied (via memory) and pasted within the very first form and passed to the file in question. <param name="FlashVars" value="xmlfile= $lanofile" /> the $lanofile is the value that I need to pass from the form to be read by this file. I have created an form (n.php) that POST the name of the folder to a second file (creatdir.php) everything is cool until I have to edit the third file. How can I pass the value of one of the formfileds to a second file and them read this value as a variable to be consumed as mentioned above? Or actually right whatever is on the third field to this position (not using variables).
Using MD5($pass) With PHP And MD5 Tables Or Password('$pass') In SQL
My intranet log in page (which starts the session) has a password field, and later once the form is submitted (after all the checking) the $pass var goes through this: $pass = MD5($pass); And my password column has MD5 encrypted passwords. I could just use password('$pass') in my SQL query and remove the MD5() from my PHP if I convert my column to "Password" instead of "MD5". So which one is safer? I think MD5 is safer and is sort of a standard so my database has a little more portability if ever needed. I have another question. My Form once submitted obviously has the non encrypted password until the variable is processed. The only way to protect this is to put the intranet on a SSL connection right?
Variables In Array?
Can you put variables in an array? Or can you cocatenate variables? For ex: When a user submits a form, they have the option of adding 5 links, so to avoid adding 10 columns to my table (5 for title 5 for url), I want to put the 5 urls into an array OR cocatenate them with a semicolon and store that in the database. Then extract it and break them up. How can I do this? Or do I need to just add the columns, or maybe just make a new table for the links altogether?
Variable Variables And Array
I need to name a form field in a variable var1[0], var1[1], var[2]. I've got no problem doing this. However this is a dynamic form, and in other instances I need the variable to be called var2[0], var2[1], var2[2] and var3[0] the next time and so on. I think the solution is somehow related to variable variables, but I can't figure it out. If I just needed var[0] and var [1] that is easy I just do: for ($x = 0; $x <3; $x++) { echo "var[$x]";} but when I try and get the variablename and the array number to increment I'm stuck: for ($i = 0; $i<$mytotal; $++) { $var= "var" . "$i"; for ($x = 0; $x <3; $x++) { echo "$var[$x]";} doesn't work because it is looking for the array $var1[0] which doesn't exist. I tried echo "$var.[$x], and everything I can think of. Somehow I think I need a variable variable but can't figure it out.
Variable-variables For Array?
This has puzzled me for a while, what's the best (most efficient) way to get something from within an multi-dim array by using a variable for the key location? Here's what I currently do. PHP Code:
Multiple Variables To Array
I have a problem where I need to add a number of variables (the number varies, but all the variables have a similar name - e.g. $rm2, $rm56, $rm6783 (they all start with 'rm' followed by a number)) to a single array. In other words, I need to add all the variables that start with 'rm' and followed by a number (e.g. $rm2, $rm56, $rm6783) to a single array.
Listing Variables In An Array
I'm currently working on some smaller extra's to add to my site. One of them requires me to input a list (using a form). The list is inputed through a textarea and every new line is seperated by a comma. I'm now trying to figure out how to list all those lines. I've worked out something along the lines of: $List = $_POST['List']; $Listarray = array(); list($Listarray[]) = explode(",",$List); foreach($Listarray as $entry){ echo "$entry";} But it only list one array element(1 list). Does anyone have an idea on how to list a whole array? (I mean with a variable amount of inputs)
Joining Array Variables From A For Loop
I have an array of items in a for loop and I would like to turn them into one variable that is separated by a pipe. Chances are they will not use one of those in any of the content.
Globalizing $_POST Array Variables
I'm trying to come up with a function that will globalize each element in the $_POST array, effectively mimicking the php.ini 'Globals = On' setting for the $_POST array. So far I've created a minimal recursive function that takes an array as argument, parses each element in the array and checks if it's an array or not, if it is an array it's passed recursively back to the function, otherwise the element is made 'global'. The function looks like this:
Use Of Undefined Constant In Array Variables
I just upgraded to 4.1.1 and the default installation sets the error reporting to all. You have the new $_COOKIE, $_POST, etc vars and all of that, too. In my page, the user will fill out a form. I set some of the values into cookeis so that when the user comes back, I can pre-populate some of the common fields and save the user some time. If I do something like this: <input type='text' name='MOS' value='<?=$_COOKIE["MOS"]?>'> Then I'll get an error like: Warning: Use of undefined constant MOS - assumed 'MOS' in /path/to/file.php on line XXX I know I can turn down error reporting on my script or in php.ini, but I'm trying to make this code as clean as possible, so I can just get rid of the warnings, instead of hiding them. I can clear this warning up by doing this: if(!isset($_COOKIE["MOS"])) { $_COOKIE["MOS"] = "31R"; } which basically gives it a default value if the variable doesn't exist. Does anyone know of a better way to "define" this array so that the warnings don't come up?
Assigning Array Elements To Variables
code below prints out the 5 values grabbed by the sql query. what im trying to do is assign these values to variables (dynamically via a loop?) so i can easily insert them in different locations on my page. Is there a way i can do something like $var0 = array element[0], $var1 = array element[1], etc? $query = "SELECT price FROM pans"; $result = mysql_query($query,$connection) or die ("problem"); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach($line as $col_value) { echo "<p>$col_value</p>"; } }
Assigning Variables From Array When Using 'group'
I want to use this query to set variables. The number of variables is consistent, but sometimes the result does not return that same number.. ie one date range may have items from group2,6 and 7, while other date ranges have items in all groups. The query: Code: "SELECT e_group, sum(amount * quantity) as total FROM expense where e_date between '$arr1_date'"." and '$dep1_date' GROUP BY e_group"; (variables for dates are already defined elswhere in the form) Here is what the table looks like: Code:
Array To Simple Variables Assignment
Am I conflating PHP with another language (PERL maybe?) or can you do an assignment to $a, $b and $c something like ($a, $b, $c) = $array? The given sytax doesn't work nor does [$a, $b, $c] = $array. This leads me to believe in the conflation theory. If there is a syntax for this,
Bind Variables To A Simple Array
I'm very new to php. In my current code I'd like to bind variables to the values of a simply (only indexed by numbers [s. http://www.php-center.de/en-html-ma...pes.array.html]) array. Of course I noticed the function extract(), but this works on string indices. So I had the following idea: <?PHP function abind($array, $names) { // Return source binding the given $names to the elements // of the simple/linear array $array. $r = ""; for ($i = 0; $i < count($names); $i++) { $r = $r."$".current($names)." = $".$array."[".$i."];"; next($names); } return $r; } function test($arr) { // create bindings for $foo, $bar and $baz by evaluating "$foo = $arr[0]; ..." eval(abind("arr", array("foo", "bar", "baz"))); return $foo."-".$bar."-".$baz; } echo test(array(1, 2, 3)); ?> Of course function test will use $foo, $bar and $baz really oftern. I could as well use $arr[0] and so on, but I'd like to use more describing variable names. In this case the eval line would make things more succint and thus improve code readability. Am I missing something? Is this a standard/idiomatic way in php or is there some other?
Telling The Difference Between Some $_FILE Array Variables
I have a form that a user fills out to submit a tutorial with maximum of 10 steps. Each step has a spot for 2 pictures to be included but the pictures aren't mandatory. Now, this is what my input fields look like for each step: Code: <input type="file" name="media[]" /><br /><input type="file" name="media[]" /> I need to figure out a way to tell the difference between the photos in each step incase the user, for example, submitted 5 steps but only the 1st and 3rd had pictures (when I call the array in the script, the pictures for step 1 would be media[0] and media[1] and step 3 would be media[2] and media[3] which is the exact same as if steps 1 and 5 only had pictures making it impossible to tell the difference between which pictures go with each step).Any ideas?
Building An Array And Passing The Variables Through Pages
I have a form that inserts a variable and then shows the variable where needed. simple... i think. I have it working, but I can't seem to add elements to the array. Also anytime I go to another section I lose the information. from the variable. here is the basic bit of code used. Code:
Deleting Database Rows From An Array Of Variables
I have a form with a list of checkboxes, which are each filled with a date in the format 27012007, for example. The name of each of the checkboxes is the same as the date. Basically when the user presses the submit button I would like all rows in the database table "users" with the corresponding column "date" to be deleted when the form variables date correspond to those in the "date" rows. I think all the checked dates might also need to be put into an array. Would anyone know how to do this?
Which Is Better, Pass, Or Not Pass By Reference?
I've asked this before but never got any response but its important and I thought I'd pitch it again (hopefully a bit clearer)... One can pass data from one function to another either by passing a copy, or passing by reference. My understanding of passing by reference (putting the & before a variable during the function declaration) means that the original data is used. My understanding of *not* passing by reference, (thus passing a copy) literally means creating a copy of the data contained in my variables - thus doubling the memory usage for this data... even if its just a temporary while the function is being executed. I *believed* (past tense) that one should only pass by reference if they wanted the child function to change the data and pass the newer values back to the parent function. I'm now thinking that this is just a feature and not the only usage. I am begining to think I should use "pass by reference" nearly all the time in order to conserve memory (since I won't be creating copies of my variable data in memory). Would this be good practice? Am I right that passing by reference means that my variable data is not duplicated thus using less memory than if I had passed my variable data as a copy?
Splitting Data Divided By Space Into Array Or Variables
I'm very new to PHP3 and just started learning three days ago. I have seen on a PHP3 tutorial that with a special command data divided by space could be splitted into an array or several variables (for picking out the words of a sentence). I just couldn't find it so far.
|