Cannot Read Information From Form Using POST Or GET ($_Post Is Empty)
I am having problems in my php code. I am relatively new to php but I
know some basics.
This is the problem:
when i try to echo some information that is typed into form back to
the screen i get absolutely nothing. It seems like $_POST['name'] is
an empty string, along with $_POST and $_GET['name'].
I looked around to see if someone else had the same problem and found
that some people's code didn't work because of IE6. but i also tried
mine on Netscape and i got the same problem.
So why is $_POST empty after posting information. Even $_GET was
empty.
all of those returned empty
echo $_POST;
echo $_POST['name'];
echo $_GET['name'];
here is the code:
the code was originially meant to send an email but i commented the if
statement out to see why it wasn't working
<html>
<head><title>Feedback</title></head>
<body>
<?php
// Handle POST method.
//if ($_POST)
//{
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
// Compose simple text message:
$message = "Message from $name
($email)
Comments:
$comments";
// Send message to bob@microsoft.com
mail("email@email.com", "Feedback", $message);
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Passing POST Information Without A Form
I have no clue if this is possible, and if it is, how to do it. Basically, I am creating a vote server system for my school, there is a central server with IIS, MySQL and PHP 5 on it, and I need to write all the pages that will get the information and display it, allowing the students to vote. I have the index page, which is nothing more than the login page, at least for now. When the student enters his / her student ID, the database checks if it exists by using this query: mysql_query('SELECT count(*) FROM `students` WHERE `snumber` = ''.$sid.'''); if the number is 1, the ID exists, if it is 0, it does not, simple. I will then transfer the person to vote.php, which will get the person's first and last name and display it at the top, then display all the vote information, and if they exist, poll questions as well. MY question is this, how would I go about transferring the person from index.php (where their student ID is validated) to vote.php where they will be allowed to vote, and also passing their student ID in a POST variable? I don't want to use vote.php to validate becuase I don't want the person to accidentally be able to vote without entering proper information. I also don't want to pass their student ID through GET for obvious reasons. IS there anything I can do?
$_POST Of Empty Vs 0 Value
working on LINUX I found that both empty($_POST['foo']) where $foo = 0 or &foo = empty gives me TRUE. I.e. I can not distingush between 0 and empty value - I need it for the text box value. What is the solution?
$_POST Is Empty (in MSIE?)
Has any of You ever experienced the problem that posted forms deliver an empty $_POST-array? I have a form like: <form method="POST" action="https://.../result.html?qid=70"> <input type="checkbox" value="1" name="1a"> <input type="checkbox" value="1" name="1b"> (...) <input type="submit" name="Answer" value="Answer"> </form> and every once in a while I get empty results (1 out of 10, maybe). This only happens in MSIE 6.0, as far as I can see, but I'm not absolutely sure. Some users have the problem all the time, some never. I use https to connect and mod_rewrite to rewrite "result.html" to "result.php"... SERVER_SOFTWARE: Apache/1.3.27 (Unix) PHP/4.3.1 mod_ssl/2.8.12 OpenSSL/0.9.6g
$_POST['emails'] Empty !?
I have a problem concerning the $_POST array. In my script I display checkboxes as much emails my textfiles contains. It's normaly stored in the $_POST array. Now I make a mark on the email's checkboxes to output - and it doesn't work. The array $_POST['emails'] is totally empty. Register globals are on and I'm using PHP 4.22 Here's the code:
$_POST Empty, $HTTP_RAW_POST_DATA Filled
We receive a POST message being a multipart/mixed type. The $HTTP_RAW_POST_DATA shows it perfectly. However, I expected the $_POST to be filled as well, which is empty. We're using php 4.3.3.
How To Read Image Header Information And Display It
How to read image header information? I have Png images which i read into the database as blob files. Now i want to get the header information from that blob(binary content).I would appreciate if some one could help me. As a try i used stream_get_meta_data function but i think it doesn't work properly.
Internet Explorer Cannot Read Header Information
I have problem about header. My code is about export mySql data to Excel header("Content-Type: application/vnd.ms-excel; name='excel'"); header("Content-disposition: attachment; filename=".date("YmdHis").".xls"); In FireFox everithing is OK but in IE cannot. I have try it at my local server with IE is OK but in real server (online) this code not work properly.
Empty Variables And 4.21 (POST/GET)
With global variables set to on, I always had the following in my script to make sure variables had a default value: if (empty($var)) { $var = 1;} Now with 4.21, I changed it to: if (empty($_GET['var'])) { $var = 1;} The problem is sometimes I use GET and sometimes I use POST. With global variables on it didn't matter. Now it does. Is there a way to do this? When I try if (empty($_GET['var']) || empty($_POST['var'])), it doesn't work because one or the other will always be empty at any one time.
From POST To GET: $_FILES Empty
I'm passing the code from $_POST to $_GET. I've a page upload using $_FILES. when the page was in $_POST, it worked fine, but now, in $_GET, the $_FILES is empty.
Problem With <SELECT Post > And $_POST()
I am cross posting to comp.lang.php and alt.comp.lang.php. I am having a problem with getting a post from a dropdownlist off a html form. While debugging, by instruction steps, for some reason I am never get passed the isset($_POST['author_pk']) after selecting an item in the dropdownlist. I have coded a simple script to duplicate what I am trying to do, just to make sure i understand it, and that works. This is the code and has to be something simple.. <?php // // Debugging $debug = false; // // Open DB include 'library/opendb.php' // This form uses the POST method, so process any post selections here if( isset($_POST['author_pk']) ) { echo 'Ok I have an author Primary Key' // do whatever you need to do with the author_pk // $sqlcmd = $author_detail_select . {$_POST['author_pk']}; // $author_detail = mysql_query($sqlcmd); } // // main form query if ($debug){ $sqlcmd = $author_dropdown_select . ' ' . limit(); echo $sqlcmd; } else { $sqlcmd = $author_dropdown_select; } $result = mysql_query($sqlcmd); if (!$result) { die('Database Error: ' . mysql_error()); exit; } // // Close DB include 'library/closedb.php' ?> /* Can't use 'PHP_SELF' under PHP Designer. Works running off server. <FORM NAME="author" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> */ <FORM NAME="author" method="post" action="PeopleQuotes.php"> <SELECT NAME="author_pk" SIZE="20" COLS="20"> <?php // a loop to populate the select options while( $row = mysql_fetch_object($result) ) { printf("<option value="%d">%s %s, %s %s %s</option> ", $row->id, $row->TITLE, $row->lastname, $row->firstname, $row->middlename, $row->SUFFIX); }
Query About Empty POST Arrays
I started programming in PHP recently and have a query about empty $_POST arrays. I can see two scenarios when this could happen. 1. When some tries to directly load the page to which data is being posted (for example, opening www.foo.com/xyz.php directly when a form action is xyz.php) 2. When the user clicks the submit button without entering anything. I am aware that Javascript validation can take care of the second case, but it's unreliable. What is the accepted way of handling the above situations on the server side? Do I just reload the calling page if the array is empty?
Problem With Post And Echo $_POST['var']
when I used metod post in a form, then i read posted variable and try to print, I have : In FORM text(variable_nr1) = 'test_var' In php <?php echo $_POST['variable_nr1']; ?> on screen : test_varvariable_nr1=test_var what's wrong on my server ?
Submit The Information Via POST
I am trying to build a script which wiil receive some user input, and submit the information via POST to a second procedure, which does some validations. If the validations fail, the original procedure is recalled, but this time the user should see an error message. The following fragment illustrates:...
Passing Sensitive Information Using GET Or POST
Basically, we have two websites which I need to pass information securely from one to the other. It is basically, login parameters and then conduct a search. I do not need to create a web service or any type of middleware solution at this time, I just need a quick and secure method of passing username/pass and the search parameters. I read a nice article (although old) that stated I could pass the data as follows, in either a cookie or a form variable. $encrypteddata = mcrypt_ecb(MCRYPT_TripleDES, "Secret key", serialize($data), MCRYPT_ENCRYPT); $encrypteddata = bin2hex($encrypteddata); $encrypteddata = hex2bin($encrypteddata); $data = unserialize(mcrypt_ecb(MCRYPT_TripleDES, "Secret key”,$encrypteddata, MCRYPT_DECRYPT)); (And yes, I do realize the mcrypt_ecb function is depreciated) However, I believe that with this solution, if I pass it in the URL, I could potentially use up the 2,000+ character limit. My question is, is there a better way to do this? Or different approach I could use?
FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the size defined in the form or larger than upload_max_filesize in php.ini, that _FILES['file']['error'] should hold an INT error code. The file upload system is working fine if the file is smaller than the defined size, but if it's larger, then both the _POST and _FILES arrays are completely empty: array(0) { } I can obviously check to see if $_FILES is set and contains elements, but I was hoping for more specific error handling (reason as to why the upload failed). Has anyone else encountered this? Any info welcomed =)
How Does PHP5 Process POST Data In Creating $_POST Array?
I need to save a wav file that is HTTP POSTed to a php page. What does PHP5 do automatically to a POSTed variable when it puts it in the $_POST[] superglobal array? I haven't been able to find any info on this.... I have a script that does what I want in PERL, but I need to do it in PHP. I think the PERL does something magic when it does this: #### PERL CODE #### read ( STDIN, $buffer, $ENV { 'CONTENT_LENGTH' } ); @pairs = split ( /&/, $buffer ); foreach $pair ( @pairs ) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM { $name } = $value; } #### END PERL CODE ####
Sending/displaying POST Information Without Using Forms
What I need to do is build onto an existing login form, using POST forms. I would like to have to have to access the existing code, so what I ultimately have to do is write a PHP script that will spoof a form POST. I have found 2-3 different examples, however none of these will send the post, and then go to that page. All that these scripts do is send the post, and keep you on the existing page. The return from the form cannot be displayed in the page with the script on it because of licensing issues. So the script needs to send the POST information to that page, just as a regular form.
Passing HTTP POST Information To Another Script - How?
I have a situation where I want to have multiple submit buttons on the same form and therefore want to use a redirection php script that checks the value associated with the submit form variable to calculate which submit was pressed and then redirects the user to another php page accordingly. I used: headers ("location:myphpscript.php") to do this. However automatically this does not pass on the information sent in the form POST. I did start looking into reencoding the $_REQUEST into a GET string to append to the URL, but this is a bit crude because the original form submit uses a post and had a lot of information (some of which is also held in $_FILES). So is there a better way to go about this? How can I simulate a POST? My second related question on this subject (I was going to post this separately but it's probably better here) is whether there is a limit to the amount of information that can be passed via an HTTP GET. I once remember reading there is a 255 character limit to a URL address and if this also includes the variable information after the ? this is quite restrictive.
Read Raw Post-Data In PHP
I need to read the RAW DATA that is sent using a HTTP-Post Command in PHP. I cannot User $HTTP_POST_VARS since the Data is not associated with a particular variable.
CGI (in PHP) Can't Read POST Data
I am trying to have a CGI script write text to a file based on input from a form. However my write.cgi's $_POST is empty. Whenever I use write.php for the action of the form $_POST has the correct data. The form uses POST method. I want to use write.cgi because only cgi scripts can write to files in my server (run by suexec) I have been researching this for two days now
How To Read The Body Of A POST Method?
I need to read the BODY of a POST. Getting normal POST variables is clear enough, just use $_POST, but the body does not seem to be included in this array. I don't have control over the POST itself (it is a notification from a mobile phone, since you ask), and the format is odd. Rather than: <name>=<value> it is: <code><space><label> eg: 900 Success How can I read the body text? I don't mind getting at the whole content and processing it, if necessary.
Empty Form
Say I have a form, a really long form, is there a way to check if all the fields in the form are empty without saying a million if statements?
Can You _POST Variables In Php Without Using A <FORM>
The question I have, is it possible for a php script which is used to validate values submitted in a form, to then post these values onto another script/page or even back to the calling form? i.e. the application I have in question is a login.htm page with a verify.php script The login.htm has a Form which captures login_id and password which are posted to verify.php verify.php checks the id and password against the database. if the check succeeds I use $_SESSION to track the logged in user into the page. if the check fails, I use $_SESSION["error"] to set an error message and then jump to login.htm, but I've lost the userid. The only way I can see of transferring the userid (and some other data) is by calling header ("Location: login.htm?id=$uid"); and then have some php code in login.htm to $GET['uid'] and pop that into the user field on the form. Is there any easy way I can post this data back without using a <FORM> or at least a form that can be auto-submitted?
Getting Form Values Without Using $_POST
I just started supporting my first php app, and am attempting to set up a development copy locally on my pc. In some places in the application, forms are submitted and the values retrieved w/o the use of $_POST['inputname'] (the form method is post.) This works on the production site, but not locally. I've made sure the php.ini is the same, and I can't find any other hints as to why this might be. Using PHP5 w/ Apache 2. I don't want to have to modify a bunch of working code I'm not yet familiar with to get it to work on my pc, thought maybe this would be a no-brainer for the experts. Sample code below. Code:
Empty Form Fields
I have a simple HTML form, which when submitted I want to check whether he fields have been completed. If everything is complete, I want to process the form....No problem with this bit. If any of the fields are not complete however, I want to indicate this......for example by placing a * character next to the field which is empty i.e. echo "<TR><TD>Username</TD><TD><INPUT TYPE=text NAME=username></TD><TD>*</TD></TR>"; I am guessing that the best way to do this is submit the page to its self, and check for any empty fields, then display the form again. What would be an efficient way of doing this, given that I have to check about 20 fields?
Best Test For Empty Form Value ?
What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST['inputTest']; if(strlen($test) < 1) // it is empty ! Maybe I can just go: if($test == '') // that's two single-quotes with nothing in between // it is empty ! At least I avoid a function call that way. Maybe there is a better way ?
Empty Value In A Form Dropdown
Think that we have one dropdown form where we can choose countries from like this. <select name="country" id="dropdown"> <option value="Choose country">Choose</option> <option value="USA">USA</option> <option value="CANADA">CANADA</option> IF I have an SELECT I can easily set country = '$country' IF user have choosen some country, but when user not choose any country the selected one is "choose", is it possible do add All countries to $country so the SELECT formula include all countrys and not just get empty?
Getting $_POST Variables From Form In A Function
I've loaded various thoughts I've collected into mysql. I want to write an app, all in one file, that has the following features: 1. On initial entry, selects and displays the thoughts ( might add pagination later - there aren't alot of records, for now.) 2. This main page includes separate forms near the top with submit buttons to search, add a thought, view all thoughts, etc. The action for each form is to call this same page. The submit buttons and thoughts are printed from a function. 3. In the main logic, I am trying to do a $_POST and if isset() on each submit button name and then call a corresponding function, do whatever it has to do, unset the form variable and continue back to the main display. The problem is that it's not calling any functions. The error log says that the name of each submit button in my $_POST[] statements in the main logic is an undefined index. I presume that they are undefined in the main logic because the forms were defined in a function. Is there anyway to access, in the same page, form variables that were declared in a function on that page?
$_POST Form Variable And Use In Same Php Page
Apache/2.0.48 (Win32) PHP/4.3.6 I would like to take a value from a checkbox(checked or unchecked) and then use that value in a php script All on the same page. So I should post the form to the same page right? And then pick that variable up via $_POST or $_REQUEST methods right? I have tried various approaches to the action= clause of the form but to no avail. I know how i did it in asp but it doesn't seem to work.
Dynamic JS Form And $_POST Array
I have a form that I am altering after page load with javascript. Basically I have a button that inserts another text field into the form which the user can fill out. Its for a calendar, and I'm allowing them to optionally add multiple days for an event. Each box that is created has the same name with [] on the end to make it an array. When I view the post array with print_r($_POST), only the first textbox's value shows up. This is the only textbox in the form when the page loads. Simplified example: <form name="calform" action="process.php" method="post"> <input name="startday[]" type="text" class="bordered" size="25" /> <input type="button" onclick="add_one_more()" value="Add another date" /> // if the user hits the add button it adds this input field after pageload <input name="startday[]" type="text" class="bordered" size="25" /> </form> And here's what I'd get from that form Array ( [startday] => Array ( [0] => test1 )) A button inside the form basically adds another <input> tag between the <form> tags. Why isn't PHP seeing the data?
Using Session $_POST On Form Submit
having a little issue with a form submit which im hoping someone has the answer to, anyone who can help me solve this I will give $10 via paypal. I have been using Session Variables for sometimes in Dreamweaver, I dont really hand code that much to be honest, so thats why i need your help. I have quite a large form which has around 25 textfields, checkboxes and Drop Down fields etc, also mutiple file fields for photos, my current issue is that the user sometimes gets a Timeout when uploading the files, when the user uses the 'Back' button all data is lost. I know it is possible to store all information into session variables just when the user submits the form. I have looked at examples on this forum and the web but found only snipplets Okay....What I really need ! An Example of a basic session, storing the variables to the Server as soon as User has press Submit on the <FORM>, it wouldn't really matter about IF Statments to check if the session exist's, if you could so an example that would be great.
Omitting Form Fields If Empty
I have a form I'm putting together. The processing will be on a PHP script that will take all the field names and print them out on the email it sends to me. No problem there. But what I'd like to do is have it exclude printing the field name and value when there are any blank values in the field. The processing part of the script is this: if (is_array($val)) { for ($z=0;$z<count($val);$z++) { $content .= "$key: $val[$z] "; } } else { $content .= "$key: $val "; } How would I adapt this to not print a field name with a blank value?
Check For Empty Form Fields
I am just starting with php (like 2 days now) and was wondering what was the best way to check for empty form fields. The code I am currently using is below but I was wondering if there was a better way to do it. Also I would like to know if my code structure/layout is ok as it is important to me to get off on the right foot. PHP Code:
When A Value Passed In Form Or Q'string Is Empty..
I am trying to figure out how to deal with when not all elements in a submitted form are filled out or when page expects a query string and doesn't get one.. I tried the two conditionals below, but still got errors: $param= $_GET['msg']; /* if ($param != "") { echo $param; } */ if (isset($param)) { echo $param; } query string is: home.php?msg=selected records have been deleted from the database. (referrer pg is not always pg sending query string.. so need to deal w/when no query string is passed..)
Show If Form Varible Not Empty
I need an alteration to my code to show region only if the form varible from the previous file is not empty. I have a list of properties in a table called employees, database name gcproperty. Some properties dont have full records in the fields (photo1, photo2, etc..........to photo9. and are empty. On the show all details page some images are blank as there is no record in the database or where drawn from the form varibles browse page that where also empty. Does this make sense? Code:
How PHP $_POST Gets The Multiple Values From A HTML Form?
I am try test a simple HTML form with PHP <form method=POST action="testing.php"> Cat <input type="checkbox" name="pet" value="cat"> Dog <input type="checkbox" name="pet" value="dog"> Pig <input type="checkbox" name="pet" value="pig"> <br> <select name="dates" multiple> <option value="Monday">Monday</option> <option value="Tuesday">Tuesday</option> <option value="Wednesday">Wednesday</option> <option value="Thursday">Thursday</option> <option value="Friday">Friday</option> <option value="Saturday">Saturday</option> <option value="Sunday">Sunday</option> </select><br> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form> When I checked cat, pig and selected Tuesday and Saturday from the form and click submitt My testing.php is <?php $pet = $_POST['pet']; $dates = $_POST['dates']; print_r($pet); var_dump($dates); ?> The $_POST['pet'] and $_POST['dates'] are NOT return as array nor multiple strings seperated with a comma. It only return the LAST string I have checked and/or selected. How do I get the multiple values from the checkbox and the multiple select from a HTML form in PHP?
Firefox Causing Empty PHP Form Variables??
This is really weird, and I would never believe it possible if it weren't actually happening to me. I've a customer database in mySQL, using PHP to create the forms, yadda yadda. All of a sudden, every time I edit a customer, when I submit the form using Firefox 1.0.2 on Linux (Fedora Core 3) it sends empty form fields to the database. BUT, if I use Firefox on Windows, or Opera on Fedora Core 3, it works perfectly fine. Any ideas what in the world could cause this? Firefox on Linux worked fine to up until...the last few days I think. The only think I can think of, is I may have installed a couple of extensions during that time.
Saving Form Information
Say I have a webpage which takes in many user inputs through a form. Once i click the submit button in the bottom the information is sent to the server. I fill in the user inputs and would like to save the webpage with in input data filled before submitting. Is it possible to save the webpage with user inputs filled?
Pass Form Information
I have a question on how to pass information from a form. I am building a simple order form for this site. I am not using a database because the person that this is for doesn't want to use a database. On the form I built a function to display the different type of products taken from the array. Each product has a Qty box and when I loop the array I put a counter in it so I can name the Qty, type, and price fields. Example: qty0, type0, price0 - qty1 Code:
Repeat Form Field Based On $_POST Data
i have a script that sets up a second page with multiple select boxes. the first script has a hidden field for the ID number, and a text input field for quantity. the second part of the script has a foreach loop that gets the info that goes with the ID number and then creates the select box next to it. for the most part it's all working correctly, but i don't know how to get the submitted "quantity" to repeat that ID number (and everything else). here is the initial form: Code:
PHP Form Keeps Resending Information On Reload.
I have PHP form that is basically a contact page when the user clicks on submit. I have the page update with your message that says it has been sent, but now if the user clicks on reload it ask to resubmit the information over again. And that's where i want to stop this so when the user clicks on reload it will not resubmit the information again. How can this be done?
Adding User Information To A Form
I need to be able to take some user details on one page and then be able to put the information gathered onto another page that already contains another form that has been created by a javascript cookie program. Thing is i need the initial user information captured to be 'pasted' in to the final ordering page and to remain there (so that more products can be added) without the user having to re input their details again. I have just started with PHP and know that i can set up a form and that PHP can print the variables from the form , but how do i get those variables to remain fixed in the next form and be able to let users go to other pages within the site without losing the data?
Form Passing Information When Submitting
I have a form that pulls mysql data to build a drop down menu, and then to obtain the page reload for a series of check boxes. When I sumbit the page I do not carry over the first value selected in the drop down. Instead I get the number associated with that particular field. just as an example: localhost/form.php?=4 Code:
Saving Form Information Into Mysql
I am looking at a way to store a list of ids from a form. What I have is a form in php that lists a group of devices that I need store in a table in a mysql database. This form is dynamic in length. ---- Sample Form ---- Device #1 Device #2 - SELECTED Device #4 Device #5 - SELECTED Device #6 Device #7 - SELECTED Device #8 - SELECTED --------------------- So I want to take 2, 5, 7, 8 and store it into a database so I can recall it later and make a report on the items selected in the form. Would an array work in this situation? What type of solution would work for this?
Displaying Information In A Update Form
I can display the information in a table. But now I need to display it in a form, so I can edit it and then upload it to the database. I have the form from my upload page, But I can not seem to get the information to appear back in it. Code:
Sending Form Information And An Attachment To My Email
Okay here is my deal. 4 to make my website. I made one page ask for user information and they attach a file. I need to know how to have the file and the info on the form to my email address! Can someone please help!?
Posting Information From A Form To A Text File
I am trying to append the results from a form to a text file. My code is supposed to print out the results on one page, and append the results to another page each time data is entered on the form and the submit button is hit. Unfortunately, it is only printing out the message acknowledging the submit button--no data on either form. Code:
|