PHP Not Populating Form Variables Passed Through POST Or GET
I"m running:
Windows Xp SP2 Apache2 PHP5 MySQL4
Everything seems fine and dandy, and I can do scripting on server side, but for some reason I cannot get data from a form to be put into a variable.
I have a simple form in an html page which submits, and in the php script that handles the input, none of the data in the form is going into the variables.
My php.ini file does have all the GPC's in place(ie variable_order, the way they get processed).
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:
Variables Not Passed From Url Or Form To Page
I use a Mac at home running OSX 10.2, and use the Apache PHP MySQL trio for developing and testing sites. I've had very good experiences with this setup and have had no major problems till now.
I noticed recently that variables added to the end of the url (the get method, ...url/page.php?var=value) are not passed to the script within the page. Forms using either the get or post method have the same problem. For example, a page named "foobar.php" containing this: Code:
XML Being Passed To PHP Via POST
I am using macromeda Flash to create anXML object which I pass to PHP. I need to know how to recieve it into PHP so I can process it in PHP. For now all I want to do is display the XML on the screen.
To start at the simplest point I am trying this:
$my_xml = $_POST; echo $my_xml;
Of course all it echos is "Array"
If I have tried a few other things, but I am shooting in the dark.
PHP:Unable To Post Variables From Html Form To Mysql Database
Plz dont treat this as another newbie query , i did my homework but still getting nowhere :( :( :(
Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to post data from html form to php file(connecting to mysql database and inserting into a table) . This seemingly simple problem is making me go mad !!! I googled extensively and already tried the following
I enabled " register_globals = On " .... in /etc/php.ini and also took used _$POST syntax.
wot could be the problem .... is it the case that /etc/php.ini file is not being read .... how do i know whether this is the default location for php.ini? Where can i find the PHPRC environment variable (the variable responsible for the php.ini default location)
Is the problem something else .....?
Following is the code ...
form.html --------- <HTML> <HEAD> <TITLE> email entry form </TITLE> </HEAD> <BODY>
<P>plz fil the form </P>
<FORM METHOD="POST" ACTON="form-handler.php">
NAME: <BR> <INPUT TYPE=TEXT NAME="givename" SIZE=25> <BR> AGE: <br> <INPUT TYPE=TEXT NAME="givenaddress" SIZE=25> <BR>
<INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML>
form-handler.php ----------------- <HTML> <HEAD> <TITLE> EMAIL FORM HANDLER </TITLE> </HEAD>
<BODY>
<? mysql_connect("localhost","root") or die("Failure on db connection");
mysql_select_db("mydb");
Variables Passed Between Functions
I have a function that fills the value field of a form with 2 possible variables but they are not getting set so when you view source you just see value=""
I also try echoing these variables to see if they are getting set but they are not. Is it becuase they need to be set to global? Code:
Passed Variables In Included Files
I'm looking for a guide on how variables are handled in included files. A pitfall I've run into is that if I define a variable, then include a file, the variable can be displayed on the included file. But if I try to call that same variables on the included page within a function, the variable is undefined. Example: PHP Code:
Eliminating Passed URL Variables For Multiple Listings On A Page
I have a page with a list of several users, each hyperlinked to another page of 'more info' about that user. The hyperlink contains the UserNumber, UserRegion, and UserStatus, and the receiving page picks up the data in the passed URL. This works well, but I'd like to eliminate the passing of these variables in the URL.
One way is to make a graphic ('More Info') that can be clicked to submit a form. Each 'More info' graphic from the dynamically created page could hold the UserNumber, but how can I pass several variables with a single click? On some pages, there can be 100+ users, and I hate to have 100+ separate forms and hidden fields.
I thought of using session variables, how can I know which user was clicked to set the session variables?
Re-populating A Form If Errors
I am learning php. I have created a simple Web page with a form. After receing the POST request, I do some error checking. In case of errors, I would like to re-post the page, but with the current values for each field.
I have organized my files like this: 1) Webpage with the form (all in html, form action points to a php file) 2) php file that receives the request.
Populating Form Text Box.
I have a PHP form for entering data on-line into a mySQL table.. Because of the intended search facility, I require one field in the form to be completed with exact and precise item names and spelling. In testing, I had achieved this with look-up tables. Ideally I would like the selected item from one of five drop-down lists to autopopulate the form text field when selected. Alternatively at least the option of copy and paste. Copy and paste - for some reason will not work. Autofill worked fine on a test form with no database connection and in standard HTML and javascript, however, once the PHP is added to the page neither method works. Could anyone please point me in the direction of how to get the autofill to work?
Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' "; $qry = mysql_query($sql) or die("Query not valid: " . mysql_error()); $res = mysql_fetch_object($qry); // This returns a row with a field 'Type' containing 'enum(...)'
$res->Type = str_replace('enum('', '', $res->Type); $res->Type = str_replace('')', '', $res->Type); //now the string is something like this: one','two','three
$temp = explode('','',$res->Type); //temp is an array with as much elements as the enum
while ($temp) print array_pop($temp);
This way is much more easier using the elements since they are elements of an array. Cleaver isn't it?
Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database:
$connection=mysql_connec ("localhost", "f2821842", "f2821842"); $result=mysql_select_db("QUERIES"); $query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'"); while($row=mysql_fetch_array($query)) {$empname=$row['emp_name'];}
<form name="webregform" action="webadmin2.php" method="post"> <input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>"> </form>
When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?
Values In Form Not Passed Using Onclick ?
i have a php file name main.php i want to do a post and not a get since this action is to delete a row in the database. however, when i try to do a href onclick, the values are not passed to the main.php. why ? Code:
echo "You have " .$votesattach. " votes for this quote. Delete the Quote and Votes ?"; echo "<form name=send1 method=post action=main.php?action='deleteit'>"; echo "<input type=hidden name=action value=deleteit>"; echo "<input type=hidden name=which value=$delete>"; echo "<input type=hidden name=userno value=$userno></form>"; echo "<a href=main.php onclick=document.send1.submit()>YES</a>";}
how do i do pass values to the server using a post method ?
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..)
Populating Form From Database, Then Passing Results To Next Page
I have a multiple select input in a form that's being populated by a row from my database as such: <input type="checkbox" name="subm[]" value="$row[ID]">
That part is working fine as I can check the displayed page using View Source and see that the value is the correct row number from the database. It is then being submitted on a form by $_POST method to another page where I want to evaluate the checkboxes and display the contents of the entire row that corresponds to each value="$row[ID]" that have been checked. But I can't seem to get it to work. I'm having a problem passing the selected value. Can someone point me in the right direction?
$query = ("SELECT * FROM `table`"); $result = mysql_query($query);
print "<p>Data for Selections:"; print "<table border=2><tr><th>You chose:";
foreach ($_POST['subm'] as $value) { print "<tr><td>"; print "$row[ID]; "; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print "</td></tr>"; print "</table> "; }
if (!isset($_POST['subm'])){ print "<p>No matching entry "; }
mysql_close();
Populating SELECT Multiple Form Field And Inserting Into Db
I have an update form where I'm trying to populate a SELECT multiple field with a list of 48 categories, from tbl work_cat. And show, as SELECTED, the one or many choices that the user had previously selected from the 48 categories which are stored in tbl cat_relations as $relation_cat.
Then allow the user to update their selections and update the database. But I can't get my form to work. First problem, I can't get the SELECT field on the form to show the categories, and then I don't know where to go from there. Below are my form page and my processing page. Code:
Populating Form In Parent Window With Value From Popup Window
I have a text box in the parent window.. now i want to populate this text box with a user_id that i will get from query within a popup window.. How do i get the value from the popup window to be passed to the main window form field in php. I know how it can be done in javascript but when i tried combining javascript and php i dont get the desired result.
Can't See My Post Variables
I work on an application which runs on our Intranet network, so security it's not a big issue, and my phpinfo() get me register_globals on (php 4.1.2 on a Debian system). The problems is that I can't see my post variables (only with $_POST) and I don't get it . Is there another setting wich overrides php.ini and stop my register_globals ->on to behave properly ?
With Variables And POST
On my online order form, I need to send a few variables to my credit-card processor. These variables are for non-secure customer comments, and will be sent through the usual metod, i.e., <form action="https://orderpage.ic3.com/hop/orderform.jsp" method="post">
However, one variable is a text-area box for a detailed customer comment, and this variable can get pretty long. But my credit-card processor has a 256 byte maximum length limit for all POSTed variables. However, I can add as many of these 256-byte variables as I like.
So how can I accomplish this in the most simple, efficient, and elegant manner? How can I break up the text-area vaiable into 256-byte pieces and then send these variables via POST along with all of the other form variables which will be POSTed through the usual HTML means?
POST/GET Into Variables
how does this look? should this by me calling ... myforms = new forms(); work by turning all key/value pairs for both get and post into variable names of the same name as the get/post key, and the variable values as the values from the post/get?
class forms { // Some stuff var $MyPosts; var $MyGets;...
Post Cookie Variables
I have a page that include on the top the result of a cookie (i come form a previous page with some inputs) in the second part of the page a form with name surname email etc etc On submit all the information (cookie + form) are sent by email... my problem is this: in the email doesn't appear the cookie values i try to create in the form tab a hidden fiel d with this value
<input name="NewEoc" type="hidden" value="<?php echo $COOKIE['NewEoc'] ?>">
Variables Past By Get And Post
I'd like a generic include that goes at the top of all pages that mysql escapes the variables past to the script. Is there a way to refer to the each of the variables past, for example (in pseudo code):
for(each $XX in (list of get/post variables)) { $$XX = mysql_escape_string($$XX); }
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.
Processing GET And POST Variables
Below is a function adapted from one found in phpMyEdit.class.php http://platon.sk/projects/release_l...hp?project_id=5 phpMyEdit is a form generator for PHP/MySQL.
I think this function works great, especially for forms where data is redisplayed due to failed validation of user input. I wonder what the opinion of other PHP users would be.
function get_cgi_var($name, $default_value = null) { // From the phpMyEdit project // Usage: $name = get_cgi_var('name'); static $magic_quotes_gpc = null; if ($magic_quotes_gpc === null) { $magic_quotes_gpc = get_magic_quotes_gpc(); } global $HTTP_GET_VARS; $var = @$HTTP_GET_VARS[$name]; if (! isset($var)) { global $HTTP_POST_VARS; $var = @$HTTP_POST_VARS[$name]; } if (isset($var)) { if ($magic_quotes_gpc) { if (is_array($var)) { foreach (array_keys($var) as $key) { $var[$key] = stripslashes(trim(strip_tags($var[$key]))); } return $var; } else { $var = stripslashes(trim(strip_tags($var))); } } } else { $var = @$default_value; } return $var; // If data is displayed/posted using htmlspecialchars($var) // return @$HTTP_POST_VARS ? html_entity_decode($var, ENT_QUOTES) : $var; };
$name = get_cgi_var('name');
POST Variables And Sockets...
I have a server that uses Cpanel, and my mail server is Cpanel's cppop. I am trying to create an email address. With an older version of Cpanel, you could use this command line through sockets.
GET /frontend/x2/mail/doaddpop.html?email=emailaddress&domain=mysite.ca&password=emailpassword"a=10 HTTP/1.0 Authorization: Basic $pass
That worked just fine because email addresses were created through GET variables. Now, they have changed it to POST variables. Now, I need to create an email address, while faking the following post variables:
email domain password quota
I know I need to use sockets, and pass the POST variables, but I have no idea how to.
Passing Variables With POST
I have a file named login.php that basically just checks if a username and password are in a MySQL database. If they aren't then it shows access denied. If they are then I want to pass the $name and $pass to project.php in a different directory. Code:
Looping Thru POST Variables
I need to know how to loop thru the variables my script receives from a form with action=post. I need to build a list of only those variables that comes from my checkboxes.
POST Variables Not Coming Through
For some reason, at random posts, the post variables don't get thru to the server. For example, if there is are two text fields: name and email... (I have register_globals on)... When I try to update the database with a query and use $name, $email, the $name is missing or the $email is missing. I am building an intranet application and all the 20 or so clients run IE. This happens very rarely. Something like once in 100 updates.
But I can see this in the log files as update contact set name="", email="asda@pol.com" where contact_id=918. Notice the name field is blank. I have JS checks in the client side which does not allow blank name field..
Is this an IE random error? How do I get over this?
POST Variables From Programs
we are trying to make a program in C++ that will comminicate with a PHP script. But we dont know how to get the variables from the program. We got it figured out with perl/CGI, but PHP seems to be a better way to connect to SQL server. On PHP the GET works, its easy, but it's not secure enough. I need informtion on what headers does the PHP require to get the POSTed data from a program.
Sending Variables As POST?
I am currently trying to send information to another page using the POST method. Unfortuantley I can not find any information on how to do this. Currently I am trying
Header ("Location: newpage.html?var=test&var2=test2");
Obviously this re-directs with the variables, but they are send using GET. Not what it need. Any ideas on how to post these variables to the new page?
Apache/PHP Post Variables
I'm working with someone on a PHP project. The other person is doing testing of scripts on their personal machine using Apache as a web server. The production server and the one I'm using are both using IIS.
This other person reports that in their PHP scripts when tested with Apache, form variable sent via the POST method are not "coming through." (This is even using the "long method" of specifying them as $HTTP_POST_VARS['x'].) These same scripts work fine on the the IIS machine (the POST variable come through).
I've looked online to see if I can find out if anything special must be specified in the Apache configuration to enable the POST method, and although I found other people posting similar problems, I saw no reference to a solution.
Not Catching The Post Variables
For some reason my PHP script is not catching the post variables that should be being sent by this form. Code:
Forward POST-variables
I have a form which should be submitted with either of two actions. Tried with javascript but this seems unreliable. Now looking at php and a processor page as the action of the form (process.php) which then sends the user to the different actionpages...can't figure out how to forward the post-variables to the different pages. Code:
Post Variables From Header Redirect
I'm using header to redirect the browser to another page and in the url I've added ?var1=value1&var2=value2 to pass some argument as get to that script, can I pass in some way, arguments as post in this case ? may I do it in both methos at the same time ?
Passing Post Variables Using Fopen()
I'm trying to pull data from a website and read it into a file the I can parse. I've done the before to site without post variables but I can seem to get my statments to work with the post. Can someone help me out?below is the code I have so far.
$url="www.somesitethatneedspostvariables.com";
$postdata = http_build_query( array( 'postvarname1' ='value1', 'postvarname2' ='value2' ) ); $opts = array('http' => array( 'method' ='POST', 'header' ='Content-type: application/x-www-form- urlencoded', 'content' =$postdata ) );
$context = stream_context_create($opts); $file = @fopen($url, "r", $content) or die("Connection Error, Please contact Webmaster ERROR CODE=0xDEADBEEF");
Get Unknown Number Of Variables From POST Or GET.
I am trying to create a page that redirects users to an advertiser's page. The reason for the redirect is statistics about who clicks where.
The situation is simple when I only need to redirect them to a page, but some of the ads on my site include forms which put data in either POST or GET and I need to know how to allow my redirect page to take that data from POST or GET, whatever that data is, and pass it on to the page that the data were intended for.
I think that once I get the data I can simply create a hidden form, on the redirect page, with the data from POST or GET already in it. However, I don't know how to get an arbitrary number of variables from POST or GET.
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.
How Can I Pass Variables Via POST In A Script?
Let's assume we have a script that only accepts POST variable input.. How is it possible to pass variables to it (using a php-script)?
How To Loop Through POST Variables And Contents
I am looking for a standard way/function to loop through all POST variables and their respective contents to update a database record.
Here's my ideal to pass a function and it update: session variable - "ID" - that holds the record ID to update $_POST or $HTTP_POST_VARS
The function would update the $_POST vaiables of the ID record with the $_POST variable's contents.
Get/Post Variables Not Showing Under Windows
I'm quite rusty with PHP and have a little issue. A script transmit parameters to itself through a simple form. It works fine when I run it on aproduction server (Linux+Apache+PHP4). When I run the same script on my development machine (Win2K+Apache2+PHP5) the submited variables don't show.
Here's some simplified code:
<HTML> <BODY>
<?php print_r ($_SERVER); print_r ($submit); switch ($submit) { // ... } ?>
<FORM METHOD=Get>Display content of:<BR> <INPUT TYPE=submit NAME=submit VALUE=APACD1> <INPUT TYPE=submit NAME=submit VALUE=APACD2> // ... </FORM>
</BODY> </HTML>
How To Process Some Variables, Then Place Them Into POST And Redirect?
I'd like to do the following in PHP. Is there a way?
Someone submits a form with data. I want to process the data, then once I'm done with it, take two of the variables, make them post variables and basically redirect the browser as if the user pressed the submit button with data filled in.
The variables can't appear in the url.
How Do You Parse Post Variables To A Popup Window?
I know this isnt really a php question but can anyone tell me how you parse post variables to a popup window, here's my code so far, im trying to pass the value entered into a radio button:
<head> <script language="JavaScript" type="text/JavaScript"> var win= null; function NewWindow(mypage,myname,w,h,scroll) { var winl = (screen.width-w)/2; var wint = (screen.height-h)/2; var settings ='height='+h+',' settings +='width='+w+',' settings +='top='+wint+',' settings +='left='+winl+',' settings +='scrollbars='+scroll+',' settings +='resizable=yes' win=window.open(mypage,myname,settings); if(parseInt(navigator.appVersion) >= 4){win.window.focus();} } <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); //--> </script> </head>
<body> <form name="answer" action="result.php" method="post"> <input type="radio" name="group1" value="Milk"> Milk<br> <input type="radio" name="group1" value="Butter"> Butter<br> <input type="radio" name="group1" value="Cheese"> Cheese<br> <input type="submit" name="submit" value="submit" src="result.php" onClick="NewWindow(this.src,'name',âÆ',âÆ','yes');retur n false" > </form> </body>
Post Variables After Java Sort Are Lost
I have an HTML table that is being constructed from a MySQL table and displays a form that includes a check box on 1 of the fields on the form for each record. I have included in this PHP program a javascript routine called sorttable.js which is something I found on the internet for sorting tables and works quite well. The HTML table includes a check box on each record so the user can select certain records for passing to the next process. This works fine unless I sort the table on some column and then the POST variables are lost. When I run the following code there are no POST variables that will echo except the submit button.
foreach ($_POST as $varName =$value){ echo ($varName . " = " . $value); }
However, if I don't sort the table the POST variables will be echoed for every record in the table. I'm not sure why this is happening or how to go about solving it. When I check certain records on the form and then sort the table the checks themself don't disappear only the POST variables do. This prevents me from looping thru the ARRAY to determine the value of the POST check box for each record to see if it was checked. If I run the above code but don't sort it I will have several hundred POST variables (several for each record).
Could someone give me an idea on how to solve this or offer some sort of work-around?
Forward To Page Alongwith Variables In POST
How to forward a page to another page alongwith the parameters passed into it
I mean I have page a.php which is called with some parameters in $_POST and I require to pass these to another page with same variables in $_POST
Passing Variables In Frame Page By Post Method
Is it possible to send variables by post method through a submit button to a frames page, and have all 3 pages in the frame pick up the variable using the $_request[var] ?In other words, I click on a submit button. in form action method call index.php the index page has a top, main, and a left frame.how do i get each one of those to receive the variable, when i can only sendit to one page? or is it possible to send it to more than one page, but only action to one page?
Problems With Error Checking / Control Of POST Variables
I have a small form that on button press submits to a PHP file for further processing into a database. I have to change the script as it allows blank / nothing to be submitted to the database. The intention is that if any of the two form fields are blank (empty) then the page is resent stating that they have to fill in all the fields to post (to a database).
If I deliberately leave the fields blank and submit the form, querying the database shows that both fields are zero / null - so nothing was entered in to the database.
However, if I use an echo command to see what is going on (before the data is entered into a database) I get the $TheName field with a "1" and the $TheComment field with an unknown entry (it doesn't echo anything to the screen - but it's not empty).
The code I've used to test this is:
$TheName = $_POST[gbName]; $TheComment = $_POST[gbComment];
if (($TheName = NULL) or ($TheComment = NULL)) { echo 'Quick error check running:<BR>' echo "Name: $TheName<BR>"; echo "Comment: $TheComment"; exit; }
This does NOT execute as these fields are not empty. It only runs if I change to:
if (($TheName = !NULL) or ($TheComment = !NULL))
Which is pointless as it will always execute with genuine entries.
Using the amended code below:
if (($TheName = !NULL) or ($TheComment = !NULL)) { echo 'Quick error check running:<BR>' }
echo "Name: $TheName<BR>"; echo "Comment: $TheComment";
I get the result that both the echoed lines are displayed as blank (no "1").
Getting Form Name From Post
how do i get the name of a form thats just been submitted i.e. here how do i get "new_form"... Code:
Form Post
i am making a form but every time it trys to send it it has to send it through outlook i wont the page to send it by its self without it coming up about outlook and stuff or is there a way i can send it to a text file if so is there a good tut for it.
Form Post
I am using 15 text areas for the user to put in 15 names. so we have user1, user2,....user15. How can I do this below:
$user1=$_POST['user1']; $user2=$_POST['user2']; $user3=$_POST['user3']; $user4=$_POST['user4']; $user5=$_POST['user5']; $user6=$_POST['user6'];
to input the data in a table without actually having to type out 15 lines.
Form POST
I am having my data emailed to me, but the data does not seem to be picking up the user's IP address, the Browser type, the URL that he/she came from, nor the email address they are entering on the form. Code:
|