Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Double Input Of Form Data When Browser Is Refreshed


I have a form page. When submitted it posts to page2.  On page 2, it inserts variable into the database. The queries the database and displays the information. But....

If the viewer refreshes their browser, it now submits the information into the database again.

Not sure how to handle problem. I think that if a session variable passed to page 2 in an if else statemen, it will keep this from happening when refreshed since the session variable is not passed in the refresh. 




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Validating Form Input Data
I am tying to come up with an elegant way to process some input data that
come from a form. When the user hits the 'Submit' button, i want the form to
appear again with the already entered valid data filled in and prompt the
user to re-enter the non-valid data. If all data is valid, i will forward to
an other .php page which enters the data into a database.

I tried to do this in the following way: the form always hits back on
itself, but when all data is valid i use the PHP:header() to redirect to the
data.php that performs the database insertion. The problem is that the data
is not available to data.php in the $_POST variable. How can i overcome this
problem? Any other subtle way to handle the whole thing?

Does Anyone Declare A Different Data Type On Every Input In A Form?
I'm trying to read up on the rfc's that govern form inputs. Much of
what I'm reading is stuff I didn't know before and some of it is
alarming. This one left with me questions:

Is this (below) addressed to me as a web designer, or is this
addressed to the makers of web browsers? Identifying the type of file
being uploaded seems way outside of my scope as a PHP coder. Am I
suppose to make clear the expected type of content when I design a
form? Off hand, I can only think of two things that every go into an
HTML form: strings and binary data. Should I actually label every
INPUT with the expected type (does anyone do this?), or can I assume
the makers of web browsers have already done that for me? My PHP form
code is fairly concise, so I could add in mime/text rather easily, but
is it necessary? Surely the browser knows that everything save binary
files is a string?

They wrote:

3.3 use of multipart/form-data

The definition of multipart/form-data is included in section 7. A
boundary is selected that does not occur in any of the data. (This
selection is sometimes done probabilisticly.) Each field of the form
is sent, in the order in which it occurs in the form, as a part of
the multipart stream. Each part identifies the INPUT name within
the
original HTML form. Each part should be labelled with an appropriate
content-type if the media type is known (e.g., inferred from the
file
extension or operating system typing information) or as
application/octet-stream.

They give the example below. Am I right to say that I don't need to
think about any of this, that the web browser does all this
automatically? The browser figures out that file2.gif is a gif image
that needs to be sent with a the header Content-type: image/gif, yes?

If the user also indicated an image file "file2.gif" for the answer
to 'What files are you sending?', the client might client might
send
back the following data:

Content-type: multipart/form-data, boundary=AaB03x

--AaB03x
content-disposition: form-data; name="field1"

Joe Blow
--AaB03x
content-disposition: form-data; name="pics"
Content-type: multipart/mixed, boundary=BbC04y

--BbC04y
Content-disposition: attachment; filename="file1.txt"

Content-Type: text/plain

... contents of file1.txt ...
--BbC04y
Content-disposition: attachment; filename="file2.gif"
Content-type: image/gif
Content-Transfer-Encoding: binary

...contents of file2.gif...
--BbC04y--
--AaB03x--

If I wanted to send multiple
files as part of a form input, how would I use the multipart/mixed
header, or the "content-transfer-encoding" header? Can anyone point me
to an example, so I might have a better chance of understanding this?

As with all multipart MIME types, each part has an optional
"Content-Type", which defaults to text/plain. If the contents of a
file are returned via filling out a form, then the file input is
identified as the appropriate media type, if known, or
"application/octet-stream". If multiple files are to be returned
as
the result of a single form entry, they should be represented as a
"multipart/mixed" part embedded within the "multipart/form-data".

Each part may be encoded and the "content-transfer-encoding" header
supplied if the value of that part does not conform to the default
encoding.

Double Quotes In Text Input
I accept text, add_slashes, and store it in my MySQL DB. When I display
the text, I normally strip_slashes and also strip_tags. This all works
excepts for a field with double quotes. e.g.

"My Book's Title" is very simple

When I display this field, it is totally blank. What's the solution?

Input, POST And Double Quotes
I am having problems with double quotes inside a post variable. The
code below illustrates this. If the user enters non-quoted text then
the code works OK. If "Hello" is entered then I get $some_text equal
to "Hello". What I want is the actual text that the user entered
and not the processed version.

<?php
if (isset($_POST['some_text']))
$some_text = $_POST['some_text'];
else
$some_text = "";
?>
<html><body>
<form method="POST" action="test.php">
<p>
<?php echo("Old text: " . htmlentities($some_text). "<br>"); ?>
Enter text: <input name="some_text" size="20"><br>
<input type="submit" value="Submit" name="Submit">
</p>
</form>
</body></html>

Pressing Browser Back Button - Form Filled Data Disappeared
When filling out a web form on a php page that is submitted to a search
which lists the results based on the criteria provided (in the form), all
works fine and as expected.

However, when I press the back button to amend the form all of the search
criteria data has gone and I have to fill it all out again if I want to do a
similar search which is frustrating. (This does not actually happen in
Firefox browser but most of my users will be using IE). How can I prevent
this from happening?

Previously I made a post about avoiding "Page has expired" and the
conclusion I came to for that was not to use a "POST" which did the trick.
But now I want to retain the data I input?

Removing Double SQL Data With IMPLODE()
The code below is a simplified version of what i am doing.  I am trying to create a comma separated list of values pulled from a table in MySQL.  This is for an easy export function of some of my stored data.  I thought that I could be clever and save some typing by using the implode() function in PHP rather than using explode() and then listing every variable in a row separated by a comma. 

The good news is that it seems to have MOSTLY worked, except that now I am getting two of everything. I think it has something to do with the $row array having multiple values for each key (maybe?...i am still not comfortable with arrays). Anyway, what do i need to do to get a single list of values, separated by a comma (and kept in the order returned by the query)? Code:

Finding Double Data In Text File
I am working on this e-mail newsletter subscription thing and I am storing the data in a txt file (mySQL is better, I know but I want it to be compatible with non-mysql systems).

Off course I don't want any e-mail adresses appearing twice in my list (the list looks like this: someone@somewhere.com, blah@bla.com, et cetera). How can I prevent this?

Preventing Double Posts On A Form
I get how it posts a random hidden form # on each page, and if its the same as the last submitted form(kept track of via session variable), it tells you its a double post (or you can put some code in to redirect to another page).

I was also wondering how to stop pressing the submit button twice. i dont think this postBlock class catches that. My only guess is to disable the submit button, onsubmit.

Double Quoted Values From Database Won't Show Up In Form
I enter user input from a form into a mysql database using addslashes. When I access values with a double quote from the database they won't show up in a text form field as the default value. I use stripslashes when accessing database values, magic_quotes_gpc is on, magic_quotes_runtime is off, magic_quotes_sybase is off.

Input Data Truncated
I have a form with <input type="text" size="whatever"> and when I enter data with a space in it the information after the space is not displayed. If, from a form the data is inserted into the MySql db, the data is complete (spaces and all), but when pulling the info out and trying to display it again, the info after the space is not there.

However, if I "View Source" on the displayed form that has the <input value=<?echo $row["city"]?>> in it, it comes out as <input value=San Diego> but the Diego does not display in the browser.

Input SQL Data Through Text Box And Get Nothing?
I want to add SQL command through a textbox in the form using post
method,but when i execute the following file, nothing is added to the
database.
I can add
$sqlol = "update acc_account
set user_name='k'
where accountid=1";
to the database if it was added to the file but when i use $result =
mysql_query($sql); which execute the query, it get nothing. However,
the $sql statement do print out on the screen using print.

<?php
$conn=mysql_connect('localhost', 'shytr8');

if(!$conn)
{print "Error- Could not connect to MYSQL";
exit;}

$er=mysql_select_db("test");

if(!$er){
print "Error- Could not create er";
$query = "CREATE DATABASE test";
mysql_query($query);}

$sql=$_POST[SQLcommand];
$result = mysql_query($sql);
?>

Extracting Data Via URL In Browser
I'm trying to learn PHP right now, and am having trouble hammering down some of the basic concepts. I've set up a database in mysql and got that working, but now I want to use that data to make writing my web pages easier.

Basically all I want to do is extract different rows of my db table dynamically by only changing what I write in the url (I've seen how on php pages, the url in the browser will sometimes look like ....index.php id=5....) so that I dont have to manually create each page with each set of data like i am now with just basic html.

Send Data To Php From Browser Url
When you open a browser and type in a url as in www.myplace.com I have seen url addresses with what appears to be a command. I.E. www.myplace.com/myfile.php?=4   

I want to know if the ?=4 at the end is the same as a POST command to the php file or can this method be used to send a command to php using the url as input?

Array Not Printing Until Refreshed
I am working on a program that inserts values into an array. The values depend on user input. The user input is gathered in flash and then I have a php script that inserts them into an array.
In php I have an index.php and global.php. The index calls the functions stored in global. First I have a function that inserts the values into the array (StoreInfo), then the array is returned. Then I have a function that prints out the values (PrintInfo). Everything works as expected except my print function displays nothing until I refresh the browser window. Also when I print the array in StoreInfo it works without having to refresh, but I am trying to make the code easy to understand. So if I do it this way, I am making it work, but also perhaps creating a disaster for someone else!
I have been told that I should consider using serialize, but I have never used it before and I am not sure how it would help. I am already using sessions to store the array. I would really appreciate it if someone could help!!

Compress Data Before Sending To Browser ?
Here I am, running a web site transfering a lot of text... data to the clients browser. I've read somewhere, I don't remember exactly that it's possible to save some bandwidth using some "gzip or mod_gzip maybe" module or ... I just don't know really...

anyone know something about this one ? so I "PIPE" the text through "gzip" send it to the browser and the browser "UNZIPS" the data and shows it on the screen ... if I'm wrong, does anyone know how I can save bandwidth when transfering TEXT ?

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?

Check An Input String For Data Types
What's the best way to check to see if an input string is made of completely letters or completely numbers? I wrote this, but it doesn't seem to work. I'll follow it with an example. Code:

Return Data Breaking Input Field
My return data is: (I have nothing to do with how the og person choose to input this)

<font color="#800080">CASE</font>

and I am setting the value of a input text form field equal to that return

$input      = "<input type="text" name="queOpt". $i ."" value="". $this->_queArr[$i] ."" />";

im lost on how to fix this. addslashes doesnt make sense  - maybe it is the double quote thing

Inserting Data Via Browser(textarea) Into Database
I just wanted to make something that creates html-code which should be
inserted in a mysql database.

The user should type text in a textarea. When the user submits the data,
all enters should be translated into "<br>" and it would be nice if the
user could also insert links ( "<a href="..." ) in the formular.

Does someone knows a good, very simple script? There are wysiwyg editors
on the net, but I don't need to modify fonts, colors et cetera. The most
important thing are the "<br>" tags which should be generated.

Content Will Not Display Until Page Refreshed
I have a web site in php that is (trying to be) a local directory.
The first and second pages (index.php and index2.php) do not appear when going to the web site unless you hit the refresh button.

The problem occurs with all I know who have visited the page.

The problem "disappears" if you visit the site and return in the same browser session -- presumably because it is now in the cache.

My first foray into php was to update and expand a local directory I had made originally coded in html. I purchased the php "site" and modified it extensively, learning a very little bit along the way about PHP and MySQL and Apache server.

I have submitted the issue to the ISP and to the program writer, each of whom points the finger at each other, and no solution.

I have searched the forums to no avail -- I found one post in WirdPress.org that is unanswered, and another post in Joomla which was ansered with several suggestions to edit the .htaccess file, none of which worked.

I have cleared my browser many times, but I doubt that is the problem (or else why would everyone who visits have the problem).

Parent Refreshed By Child Window
I wonder if I could refresh parent window in PHP when I close child. I know
that I can refresh but I need to keep entered data which I have in parent
window.

Keeping The Same Session_id When A Page Is Refreshed
I have the following script:

<?PHP
session_start();
echo session_id();
?>

But it gives a different session_ID() everytime the page is reloaded.
Is there any way to keep the same session_ID() until the browser window
is closed?

Input Form
First question:

I have an input form that upon pressing a button validates the values
entered into this form. I am using the following code recall this form if
there is an error in one of the requested fields:

<form name="form1" method="post" action= "InputForm.php" >

All works fine. However, if there is an error and this form is recalled, all
the fields are blanked out when you are brought back to the form. I'd like
for the form to retain the values that had been entered. How do I do this?

Second question:

For the fields that are in error, I'd like for the titles for the fields to
display an asterisk and change the text to red. Have any of you done this
and if so how do you implement it?

Input Form With Same Name
I have a problem with a form that it has of the input with the same
name: I cannot modify code HTML inserting [ ], in the variable $_POST
is always a single value, like I can recover also the others?

Input Form
I'm trying to set up an input form so when I enter information using the input form the info I type in is sent to another page and placed in a table. That I already have set up but when I hit the refresh button the data in the table is erased. Code:

Passing Variable Through Hidden Input Drops Data
I have a form that is filled out that is passed to a preview page so the user can validate the changes they're making. On the preview page, they review their changes and hit the "Submit" button to have the data changed in the database.

The preview page submits the data to the page that does the work using hidden inputs like: PHP Code:

Creating Hyperlinks From Data Input To Be Display In Table
Ive used search functions and have found relevent thread but the coding does not match. I have a php page the displays records from a form. id  name, address, phone, website etc

I would like to make the website data to turn into a hyperlink once submitted. Here is my following php code that displays the table Code:

Make Data Safe To Input To Mysql Database
I'm just wondering what kind of things I should do to make sure that inputs from a form are safe to put into a mysql table?

I'm currently using ereg() on an input to make sure that only numbers are entered, but on other forms I've got thiongs such as names and other details. How do I make sure that they're not going to break my table?

Posting Form Data And Also Allow To Download Form Data
i have a client that whats to post form data to a database but he also wants users of the script to download it aswell how will i got about doing this i thought about it that i could make it save it into a txt file then echo the download link is there any ideas? because to post it to a txt file it would be posting 2 places is there a way to do this? Code:

Displaying Binary Data To Browser And Set Mime Type
I am looking for a link or help on how to set the
mime type in my php script as well as send binary data to the browser
window instead of having it ask me to save the file.

Stop File Reload When Page Is Refreshed
I have a section of PHP code at the beginning of the page that loads a file which the user has specified in the form, on the same page. The problem is that everytime the page is refresh with the refresh button, the file loads. I want the file loading to happen only if the user has pressed the submit buttom.

Form Input Must Be Multiples Of...
I am trying to make an order form and i want to make sure the quantity input is in multiples of 20. I don't want to use a drop-down box because the range can be 0-1000. Is there a function that will return whether a value is an integer?

Capturing Input From A Form
I currently have a search form on my website. When you type something in, it redirects you to a page that displays the results. I would also like the users searches to get input into an access database at the same time.

How would I do this?

Form Input Into Arrays?
When passing form inputs to another php page, I know that a form field named field1 will pass the value to the next page in a variable named $field1.

However, is it possible to pass the field directly into an array? I ask this, because my forms are generated dynamically, and each form field is numbered - so I would like to pass the values into the appropriately numbered slot in the array for the next page.

I Want To Use PHP To Process Input From A Form
I want to use PHP to process input from a form,
How can I do it?

Checking Form Input
Well i've eventually manage to get a comments system working on my site, adding information etc. however i want to add a few saftey precausions.

I.e prevent use of HTML commands been enterend into a comment or holding down a single key, that can often lead to tables been pushed out of size, thus messing up the site. i have been using a function that strips out swear words, this works fine, I included an option to remove HTML etc... using PHP Code:

Formatting Form Input
I have a simple lweblog that I made for a website using php and mysql but I noticed that what I enter in the form is not what gets outputted. I want to have returns and spaces and and things like that. Does anyone know where a good place to learn how to do something like this? Or maybe tell me what to put in my code?

Capturing Form Input
I will try to be short and to the point.(good Luck) I have a form
written in HTML. I have a Mysql database. I am using a linux server
and I would like to use php to write the following code:

After the user inputs their name, address, email, phone, etc. in my
html form. They will hit the submit button. I need for the information
they entered to go into my database.

I have looked now for about 12 hours and haven't been able to find an
answer. I know I must be missing something since I've been to the w3
site, codewalkers, phpfreaks,php.net(?), and many more.

If there is an easier way of doing this I would love to hear it.

If somene could point me in the right direction I could stop banging
my head and pulling my hair.

Capitalization Of Web Form Input
I'm using PHP to submit form input to MySQL and need a way to
capitalize the first character for certain fields. Does anyone know of
some way to achieve this?

Plus Minus Form Input Box
Can any one help me with a script that will increase or decrease the value in a form input box each time either a plus or minus charachter is clicked on?

Much like what you would have in a shopping cart, a form input box with say a number 1 default in it, you will have a + and - charaters next to the box and if you click on the + the number in the box will increment 1 and if you click on - it will decrement 1.

Rendering Form Input
I created a basic forum. If someone tries to post something like the following:
I ' m   r e a l l y   b o r e d .It comes out like this:

I ' m r e a l l y b o r e d .I know it's an HTML limitation.

What can I do so what it will render every character typed? Here's my code:

Cleaning Up User Form Input In Php
Does anyone please know why when trying to clear up user input that has been entered into a form, php only clears up most of it and not all?

For example, using stripslashes to remove all slashes from a variable after a user has submitted quotation marks ("") into a form.

The quotation marks cause the variable being parsed to contain slashes.

e.g. a user enters """""" into a form , the variable returned to php becomes """""

So if I only wanted the quotation marks, I thought the stripslashes function would achieve this.
However, it only removes 3 of the 5 slashes leaving 2 unwanted slashes behind.

Keep The User’s Input Showing In The Form
I am working on a model which contains more than ten pages. There is a form on each page to let the user enter the information. I used session to store the user’s input for each form, so I don’t need pass the input information from each form with $_POST[‘smth’] all the way down to the last page which calculates the result based on the input. My question is HOW TO KEEP THE USER’S INPUT SHOWING IN THE FORM, so when the same user wants to do another calculation by changing only a few inputs not all, the user can only change the one he wants to change, all the other information stay the same as the last round of calculation. For example, the program requires the age, # of courses taking, the score for each course. When the user wants to use this model more than once and he/she only need change the score for each course, all the other information still use the input from the first round. Do any of you have any ideas? I hope I have described my question clear enough for you to understand.

Form Input Error Checking
Have a form field being inserted, needs to only allow an integer value through. Which function do I want to use to check the passed var to see if there are any non-integer values present? PHP Code:

How To Limit Form Field Input?
I'm wondering if there is an easy way to limit a user's input in a text field to 1000 characters?

Contingency For Form Input When Db Is Offline
My mysql server and web server are on different machines. Potentially, the db server may be offline, but requests to add to the db may still happen. I would like to develop a contingency plan so when the php script can't connect to the db, it writes the form data in a text file and sends someone an email, with a link to process the information later.

My problem is there are textarea boxes on the form, so potentially the data could contain hard returns and such, which will throw off a script that would use file() and parse each line for a separate query. What other options do I have?

Form Processing With Input Validations
I am creating a form Form1.php that posts to the another form
Form2.php.

I have input validations on the first form. I need the user to go to
the next form ONLY if the inputs from the user are valid. I have not
been able figure out how to do this since the first form always posts
to the next form no matter what.

I would really appreciate if somebody can share their php knowledge
and give me some idea on how this is done in php.

Quotation Marks In Form Input
I have a form which contains a field for "height".

If someone places an entry such as: 5&#396;" the form seems like it completely
empties that value.

It does NOT do this on my machine, but does on the client's machine, which
leads me to believe it is something with their php configuration.

Any ideas on what this is (and how I can work around it?)

Duplicate Input In 2 Form Fields
Hope to check the input in two form fields:

input in "emailto" form field: a@a.com
input in "emailfrom" form field: a@a.com, b@b.com, c@c.com

I hope to remove the duplicated input "b@b.com" in "emailfrom" form output and then keep only the remaining part of the string. How can I do that? I have though a way in combining the two fields input as an array and then use "array_unique" to check the duplicate. And then, to separate the two fields input again.


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