Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    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.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Browser Refresh Causing Session Variable To Come Up Empty
Can anyone tell why the following code:

<?php
session_start();
include "html.php";
include "./common_db.inc";
$time = $_SESSION['Time'];
$user = $_SESSION['User'];
$now = time();
echo "TIME1: $time<BR>NOW: $now";
if($now > ($time + 1200))
{
$query2 = "UPDATE users SET online = 'n' WHERE username = '$user'";
$result2 = mysql_query($query2);
session_destroy();
/* ?>
<script language=javascript>
window.parent.location.href = "index.php";
</script>
<? */
}
else
{
$now = time();
$_SESSION['Time'] = $now;
$time = $_SESSION['Time'];
echo "<BR>TIME2: $time";
}

?>

Would initally return:

TIME1: 1046151365
NOW: 1046151365
TIME2: 1046151365

And after refreshing the browser a couple of times it returns:

TIME1:
NOW: 1046151511
Warning: Session object destruction failed in c:inetpubwwwrootdiningsess_mgmt.php on line 14
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:inetpubwwwrootdininginbox.php on line 47


Obviously the session variable isn't returning a value after refreshing the browser. but why would that be??!?!?!!? sorry i'm not too well versed in sessions and any help you can provide is definitely appreciated....

Error Message Causing Form Inputs To Clear
My problem is this: I built a simple form that connects to a sql database and inputs the information. I made it so it puts the error message at the top of the page, when the user leaves a required field blank, password is too short and so on. The problem is that it clears all the fields when it displays these error messages.

Is there a way to prevent this so it doesn't all have to be entered again. Am I just going about this the totally wrong way? I really haven't been working with php that long, about a week really, so excuse me if this is a total noob question. Code:

Submitting Form Not Working In Firefox
I have put this in Javascript section but there are no users in there so I hope it is ok to put in here too. I have the following code which works with IE but not in Firefox:

<!--
function changestudent(){
 document.getElementById('status').value = 'remove_image';

 add_edit.submit();
}
-->

It is linked to a remove image button which when clicked submits and saves the form and then removes the image. It works in IE but not firefox, anyone know?

PHP Variables Are Always Empty
I'm trying to write a PHP script which allows to enter an username and a
password and to click two buttons.
If I start my PHP scripts 'mytest.php' I see the two input fields and the
two buttons. However if I enter something to the input fields and press a
button the echo commands show nothing.

======

PHP script 'mytest.php'
-----------------------

<?php
session_start();

if (!isset($_SESSION['auth_ok'])) {
$_SESSION['auth_ok'] = false;
}

echo "$user <br>";
echo "$pass <br>";
echo "$button1 <br>";
echo "$button2 <br>";
echo "$auth_ok <br>";

if (isset($button1)){
echo "Button 1 has been pressed<br>";
$auth_ok = true;

Empty Variables In 4.2.1+
I have a site where I check to see if a variable isset to see which file I include on a page - the URL would be something like: http://www.domain.com/?s

Then in the PHP file I check to see: PHP Code:

Testing For Empty Variables
I am retreiving the results from a randomized multiple choice quiz sent from a another php page using:

foreach($_POST AS $field=>$value){

How do I check to see which questions were not checked?

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.

Empty Variables In Forms
I have some functions that check to see if certain form variables are empty. If they are empty then the function returns a 0. All of that is working just fine. BUT, I cant get the script to see the 0. PHP Code:

Checking For Empty Variables
Can I use empty() to check to see if variables actually have data? Basically I want the script or something to check to see if there is data in the variables. If there is no data, give the user some instructions on writing some data (link to a form or admin panel). If there is data, then continue with writing to the database.

If(empty) Statements/session Variables
1. I have a 2 page form. When the user fills out the info on page form he is directed to the 2nd page of the form. A session variable has been created in the 2nd form to hold all the data from the 1st page. When the 2nd page is submitted all the data (stored from page 1 and new from page 2) are sent to the database.

2. Here is the problem. On page 1, I have several form fields (like combo boxes) that need to work together. For example: I have a text field (name=phylum) in which investigators add new phylum names which are eventually sent to database field "phylum" of the same name. Next to that is a select box (name=newphylum) that has all the names that the investigors have previously entered and that are dynamically retrieved from the database field "phylum".

So when a researcher fills out page 1 of the form he/she can either add a new name or select an already existing name from the select box. But just one of these values can be sent to the database, not both.

QUESTION 1: How can I say and where would I put something that basically says the following: if the phylum text field is left EMPTY (i.e. they don´t add a new name) and they select instead from the select box, that it is the value from the select box and not the text box that gets sent to the database.

QUESTION 2: How do I pass the statement from question 1 into the session variable on page 2 of my form?

Creating Empty Variables For Input Data
I am creating a script that will be taking data from a POST and submitting
the data to variables which are placed within a hash for string to data
association. Then, using HTML::Table and Mail::Sendmail, the data is parsed
into an html table and then an email is created and send to a recipient.
So, my question is this; How do I take the input from a post form and have
the variables pick up the data and process it into a hash?

my $name = ;
my $instock = ;
my describe = ;
# Hash to hold inventory data
my %table_data = (
model ='$modelnumber',
item ='$name',
available ='$instock',
description ='$describe',
);

This is all the code I have written thus far, any pointers or suggestions
for this project?

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?

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? 

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:

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);


Ftp_nlist Returns False For Empty Directory Instead Of Empty Array
In an application installed with PHP5 it looks like ftp_nlist() returns
false if the directory is empty, instead of an empty array as it should
according to the manual. On the original server with PHP4 it works as
expected.

Is this a bug, or an undocumented change in PHP5, or a setting that
could be changed somewhere?

Form Variables To Session Variables
I am writing a small script that consists of two pages:  page one displays a bunch of values from a DB (ie. First Name, Last Name, Phone Number).  On this page you will find a form that follows this format:

<input type="text" name="edit_firstname" size="20" maxlength="35" value='Bob'>
<input type="text" name="edit_lastname" size="20" maxlength="35" value='Smith'>
<input type="text" name="edit_phone" size="20" maxlength="35" value='5552222'>

So when you see the page there will already be a 'default' value in each line (which is information extracted from a DB).  This works perfectly and has been tested thoroughly.

On the second page I have the following code:

$editfirstname = $_POST['edit_firstname'];
$editlastname = $_POST['edit_lastname'];
$editphone = $_POST['edit_phone'];

What I am trying to do is this:  the default value for edit_firstname from the form is 'Bob' by default, but the user can change this in the input field on the first page.  This value, whether changed or unchanged, should then be stored as edit_firstname and by calling up the function $_POST[''] on the second page I want to transfer the value to the variable $editfirstname. 

However, it seems that $_POST['edit_firstname'] and the other fields do not return a value at all, hence $editfirstname = '' or $editfirstname = 'NULL'.  I have never tried to do things this way before. 

Need Help With PHP Causing High Load
I've redesigned my site. I went from a design that used SSI to include files for navigation and ads to PHP pages.

PHP is used in the pages for include files mostly. I also have a PHP image rotation script.

I'm on a dedicated server. Since I've switched over the load has gone off the charts-see the image.

How could PHP pages cause the load to do this??

Are there things I can tweak on the server?

You can see the PHP code here:

MSVCRT.dll Causing Problems
I'm running Apache w/MySQL & PHP 4 on Windows ME and I have a script that inserts MP3 ID3 tag info into my database. The problem is that once it gets to between 20-40 entries the routine crashes and tells me that the MSVCRT.dll has caused an error. Any idea what may be causing this or how it can be fixed?

In an unrelated issue, when I run the script to enter the ID3 tags for some reason my auto-incremented ID field doesn't auto-increment; all entries are given the same ID. Nowhere in the INSERT query do I even mention the ID field, so I'm having trouble rationalizing how the ID's aren't auto-incrementing. Hope someone knows what's going on...

Shell_exec Causing CGI ERROR
I have a php page that needs to call a batch script. My test script
has one line: echo test.

I am running Win2003 Server, IIS, and php 4.3.10.

When I first tried running my php script I got an error that said
"unable to execute ...". Then I granted the IIS user execute
privledges to cmd.exe (I know, I know ... security risk).

Once I did that, my script gives me a CGI ERROR - something about http
headers.

I've scoured google groups and come up with nothing that works. I
tried one solution that uses an executable called bgrun.exe. That exe
calls my batch script - still no luck. I've tried exec() and
shell_exec(). No difference. I've tried saving the result to a
variable and not. No difference.

Cookies Causing Errors
when runing my login code i get the following warning caused by the cookies that are being made and the function header() to redirect to another page.

Warning: Cannot modify header information - headers already sent by .....

what is the reason for this error?is it due to something with WAMP5 and it not being on a real server or is it my code?

"s In Text Causing Problems
I'm still learning php and I've come to something that I think should be able to be done, but I can't seem to find it.
when I put a story(text) in a variable I have to add the in front of every ".

Is there any function that you can make a story(text) stay the same rather then change all the "s to "s?

Require File Is Causing Error
I have a function in a file called tCalc.php, here's the content:

<?php
function calcElapsedTime($time)
{ // calculate elapsed time (in seconds!)
$diff = time()-$time;
$daysDiff = floor($diff/60/60/24);
$diff -= $daysDiff*60*60*24;
$hrsDiff = floor($diff/60/60);
$diff -= $hrsDiff*60*60;
$minsDiff = floor($diff/60);
$diff -= $minsDiff*60;
$secsDiff = $diff;
return ('(elapsed time '.$daysDiff.'d '.$hrsDiff.'h '.$minsDiff.'m
'.$secsDiff.'s)');
}
?>

The function works fine when in the page2.php. But when I take it out and
add this line, it doesn't process:
require_once('tCalc.php');

tCalc.php is in the same directory as page2.php.

PHP Scripts Causing (big!) Memory Leaks?
I'm experiencing big memory problems on my webserver. First on an old
RedHat 7.2 system, now on an other fresh installed Suse 8.2 system:

Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3
20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003
Apache 1.3.27-41
PHP 4.3.1-52
MySQL 3.23.55-20

Problem is that the system is running out of memory after a while due
to memory leaks, then it starts (almost randomly) killing processes:

dmesg:
__alloc_pages: 0-order allocation failed (gfp=0xf0/0)
__alloc_pages: 0-order allocation failed (gfp=0x1d2/0)
VM: killing process httpd

The memory leak is in the httpd process (thus in Apache, PHP or my
scripts). It grows (within hours) to several hundreds (!) of MB. To
limit the impact of the leaks I changed /etc/httpd/httpd.conf:
MaxRequestsPerChild 10000

This gave the system some breath: after this change the httpd
processes only take a maximum of 12 MB (scripts may take 8 MB as
configured in /etc/php.ini, the rest is probably taken by Apache).

Does anyone of you guys know of existing memory leaks in the above
Apache and PHP packages? It is possible that I have memory leaks in my
script, but I don't understand why they are causing problems now
(after running for over a year without problems).

Iframe Causing 2 Scroll Bars
used iframe to remove frames. Now problem is that its showing 2 scroll bars for some pages calling data from yahoo store. Now, i need to get one scroll bar. I increased the size but it effects all the pages. Now other pages are showing lot of blank spage at the bottom.

Is there any way to resolve it by using any script or any other technique...

Session Causing My Field To Clear!
i have a registration form that receives user's input like firstname,lastname..etc. and of course a validation. the problem is when a user mistakenly inputs a wrong validation and tries to submit it the error message and the fields are cleared, and i think it's wrong it should still display the user's input. here is my code:

Graphics() Function Is Causing The Script To Choke
I've been staring at this script for the last half hour, something in the graphics() function is causing the script to choke.

When I add it in, the script stops working entirely (but no error message), without it, obviously the section that calls graphics() doesn't work, but everything else does, anyone have any ideas what's wrong?

PHP Code:

Include A Php Script Without Causing A Parse Error
i am trying to find a way of doing this that won't generate a parse error,the problem arises from calling a file that has php code inside that file, when you do it the way below it generates the error and I was wondering in thier is a way around this or another way I can do this.

<?php
if ($action == "addproduct")
{ include("templates/templ_addproduct.php");
}
if ($action == "viewproducts")
{ include("templates/templ_viewproducts.php");
}
else
//state that neither is showing up
{ print "neither addproducts or viewproducts was selected";

}
?>

Queries Causing Page To Load Slowly
I'm currently having trouble getting a looped query to display the results in as quick a time as possible. At the moment the query takes far to long...and that's if it executes at all. At the moment i have around 3000 movie titles in the DB.

Can anyone suggest a way of populating the select box in a relatively quick manner?
Here is the code: PHP Code:

Variable Length Causing Display Problems?
I am trying to insert the contents of a PHP variable into a MySQL database using the following code: PHP Code:

Trying To Setup Php_oracle.dll Causing Error During Service Startup
I am running PHP version 4.3.4
I am running an Apache server
I am running on Windows 2000

My PHP server has run perfectly since it was installed last November.
However, I just uncommented the line (I need PHP to interface with an
Oracle database):

extension=php_oracle.dll

And my Apache 9iAS service for Oracle will not start now. I am getting
"Could not start the Oracleoro9iasHTTPServer service on Local
Computer. Error 1067: The process terminated unexpectedly." The line
php_oci8.dll installs just fine when commented out and does not cause
an error. Why is this happening?

I have put the php_oracle.dll file into the target directory. I am not
sure why this is causing the HTTP 9ias server service not to start.

Following Up Form Variables
i've coded a website to take information from a user, and then output it to a printable page to send in. The site is actually for a non-profit org, and this is for a contribution form.

I have a checkbox place to put into a variable called $bird[]. $bird[] prints out fine on the page directly after, but how do I keep the value of it and send that variable on to the next page? So on the next page I can also print out the value of $bird[]. On the second page, I used: PHP Code:

Form Variables
Wonder if there is any way to check all variables through a loop when a form is submitted.
I have few checkboxes (chk1,chk2,chk3...) in a form and in a php file I wanted to go through a loop to check which checkbox is 'on' and then so something with that variable.

Using Variables From Form
I've just started learning php and I hope you guys could help me with
this problem. I've found a useful pice of code from a book to make a form
and I would like to use it. I would like to print the variables (input)
on the screen , but I can't make it work. I think I have to do something
with an array, but don't know what. I've tried

$field = $_POST['field'];
echo $field;

and also

$arr = $_POST['array'];
print_r($arr);

but it doesn't work.

Could some one show me what I'm missing?

########################### code ###################################

<?php

// new function
echo "<br><br><h4>second function</h4>
";

function print_form($action="", $method="post")
{
if (empty($action)){return FALSE;}
echo "<form action=$action method=$method>
";
$numargs = func_num_args();
for($i = 2; $i < $numargs; $i++)
{
echo "$i <input type = text name =". func_get_args($i) . ">
<br>
";
}
echo "<input type=submit>";

echo "</form>";
}
print_form("autoform2.php", "", "field", "field2", "field3", "field4");

// testing if the variable exist...and it doesn't...
if(isset($_POST['field'])){
echo "exist";
}
else {
echo "does not exist!";
}

?>

########################### end code ##################################

Form Variables Without Submit
Is there a way to pass variables from a form to PHP without submitting the form? ie. retrieving a user's selection from a picklist or checkbox.

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?

Find Form Variables
Is there a way to read the variable names passed by a form if you dont know their names.
I have a site where the users can edit a form but I need to then process it.

Passing Variables From A Form
Well I am having some strange problems with a web-based form that is used for users to submit data. I have moved the form and accompanying PHP files across from a Redhat 7.3 install to a new Redhat 9 server running Apache 2.0.40-21, with php-4.2.2-17. So, it is stock standard. Everything was working ok on the Redhat 7.3 install. The troubles I have run into is when I try and pass a variable from a form such as below: Code:

Passing Form Variables To A Pop-up
I've searched the forums for this, but haven't seen any posts or solutions about this particular problem...I have a form in a php script that submits like this: Code:

Form Variables Gone Missing
hope I'm on-topic here - couldn't find any leads with a search so
maybe someone has an idea.

I've got a PHP form that is supposed to set some variables from
its fields and then call itself by the POST method.

Here is e.g. a minimal test version called "top.php":-

#!/usr/bin/php
Content-type: text/html

<HTML>

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old! <br>
Welcome <?php echo $name; ?>.<br />
You are <?php echo $age; ?> years old! <br>

<form action="top.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

<? phpinfo(); ?>

</HTML>

When I enter data in the fields name or age, it just gets ignored,
goes missing, thrown away by PHP. The first 4 lines that should
output this info show that the variables are all blank.

The phpinfo() call at the end shows me clearly that register_globals
is on.

The only way I've found so far is with the GET method - there the
expected arrays and variables are also broken,
but $_SERVER["REQUEST_URI"] is correctly set (yipee!) and so
I can parse that myself - sort of defeats the point of PHP though.

What could be the problem here?
Is there some other setting I'm missing?
This stuff all worked without a hitch in PHP3 - has something
else been broken in the name of security?

Passing Variables Through A Form
I have a setup where I am displaying lots of information, all of it comes from contact forms and is stored in a database. Then can be viewed on one page, through the scripts. One feature is that you can click on an email address to send an email to that specific user. When you click their email, the form comes up fine, and I have been playing with this for awhile.. I am having trouble getting the variables passed through so that I can send the email and update the database. Code:

Passing Form Variables
I'm trying to make a page that will let you change the order in which some items are displayed. The problem I'm having is passing back the id value of the item that you want to move up or down in the display order. Here is the code:

Passing Form Variables
Is there a way to read the variable names passed by a form if you dont know their names. I have a site where the users can edit a form but I need to then process it.

Session Variables In A Form
i want to create a form that updates a users account details...is there a way that i can get the form to show the users current details in each text box? then the user clicks on that box to edit the deails?

also how would i structure a query so that it only updates the edited fields? and keeps the rest the same? Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved