Jul 26, 2008

Php & Forms Question

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Php & Forms Question

awesomebill61
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']?

 

 

 


Reply

jlhaslip
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.

Reply

awesomebill61
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";
};

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : php, and, forms

  1. Restrictions On Php & Forms?
    $_GET/POST/REQUEST? (2)
  2. [php]simple Flat File Text Manipulator
    Example on how to use forms to write to files in PHP (3)
    I made a simple flat file text editor, that can show you probably how simple it is to use forms with
    php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
    is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
    are. Here's the file with comments. I think that HTML really doesn't need some more
    explaining. CODE Title: <br /> <input type="text"
    name="title" size="53"> <br /> Text: <br />
    <textarea nam....
  3. Forms, Text Files, And Php For A Signature Generator.
    Help a little. (1)
    Hello everyone! I am in need of some code a for a signature generator I am making. I am using
    BuffaloHELP's code for the php file, now I am trying to improve that code by making a form in a
    html file that will have the user say what is on the sig! But now, I need help getting the form
    data that is posted by the user to get into that sig! There is a file, sig.txt, where that tells
    the php file what text will go on the sig. But how can I make the form data in the html file go into
    the text file so it will go onto the sig? You might want to read BuffaloHELP&....
  4. Protecting Web Email Forms
    (3)
    i have a web form on my site which can be filled in with a customers email, name and question or
    comment. when the form is submitted an email is sent to an address i setup with all the info.
    recently i've been getting alot of spam/junk coming from the web form. for the most part, they
    usually come pretty close together, which makes it seem like just one spammer (at least at a time).
    also i'm talking like 5-10 messages at a time. i'm wondering if people have any
    suggestions how to protect these types of web forms from spammers. any ideas/help is appreciate....
  5. How Do You Validate Your Forms?
    (3)
    Hi Do you validate your forms using PHP , javascript or both? I was just playing around with a
    tutorial for a very simple guestbook and the creator did use both javascript and php to validate.
    Thanks Patrick....
  6. Php Contact Form
    contact forms made easy... (7)
    Here is a simple script to make a contact form with PHP. First off you make a simple contact form,
    insert the following into any page: CODE <form method="post"
    action="form.php"> Name:<input name="name" type="text"
    id="name"><br> Email:<input name="email" type="text"
    id="email"><br> Subject:<input name="subject"
    type="text" id="subject"><br> Message:<textarea
    name="comments" id="textarea"&....

    1. Looking for php, and, forms

Searching Video's for php, and, forms
advertisement



Php & Forms Question



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE