Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php & Forms Question
awesomebill61
post Jan 31 2008, 12:24 AM
Post #1


Newbie [Level 3]
***

Group: [HOSTED]
Posts: 48
Joined: 21-January 08
Member No.: 56,591



okay, so i have a form on a php script i am working on, and i want the form to submit to the page it is on...
CODE
echo "<form action=\"" . $_SERVER['REQUEST_URI'] . "\" method=\"GET\"> \n";

so say the page it loads on is something like index.php?page=article&id=8
when i submit the form, it ignores the query string and just goes back to index.php
i tried something like
CODE
$action = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];
echo "<center><br/>\n<form action=\"" . $action . "\" method=\"GET\"> \n";

or
CODE
$action = $_SERVER['SCRIPT_NAME'] . "?" . $_SERVER['QUERY_STRING'];
echo "<form action=\"" . $action . "\" method=\"GET\"> \n";


is there anyway around this still using a form? if not, i could just list the form options as hyperlinks and pass the variable on through that, or i could just have the website reload to the home page whenever someone updates the theme.

also, a question of curiosity, what is the difference between $_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME']?
Go to the top of the page
 
+Quote Post
jlhaslip
post Jan 31 2008, 03:19 AM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 4,072
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol



Check this link out for definitions relating to the final question you asked above.
Both of these are 'Pre-Defined Variables' in PHP.

http://ca.php.net/reserved.variables

Edit the script and echo out the variables in question. That is a standard de-bug technique in most Development Environments. Have the machine tell you what you have done and see if it matches what you 'think' you asked for.

Also, inside the script, have the php_info () called for output. That will list all of the SERVER ARRAY which relate to the script and then you might get a better picutre of the differences in the Server Array contents.
Go to the top of the page
 
+Quote Post
awesomebill61
post Jan 31 2008, 04:13 AM
Post #3


Newbie [Level 3]
***

Group: [HOSTED]
Posts: 48
Joined: 21-January 08
Member No.: 56,591



QUOTE(jlhaslip @ Jan 30 2008, 09:19 PM) *
Check this link out for definitions relating to the final question you asked above.
Both of these are 'Pre-Defined Variables' in PHP.

http://ca.php.net/reserved.variables

Edit the script and echo out the variables in question. That is a standard de-bug technique in most Development Environments. Have the machine tell you what you have done and see if it matches what you 'think' you asked for.

Also, inside the script, have the php_info () called for output. That will list all of the SERVER ARRAY which relate to the script and then you might get a better picutre of the differences in the Server Array contents.

yea, i had seen that page before, but it didn't really clarify much for me... and calling php_info(), they both return the same value every time.



and also, i answered my own question... i just added this block of code inside my form to re-set all of the values:
CODE
foreach($_GET as $key => $value){
    echo "<input type=\"hidden\" name=\"$key\" value=\"$value\" />\n";
};
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Protecting Web Email Forms(3)
  2. Forms, Text Files, And Php For A Signature Generator.(1)
  3. [php]simple Flat File Text Manipulator(3)
  4. Restrictions On Php & Forms?(2)


 



- Lo-Fi Version Time is now: 11th October 2008 - 08:37 PM