Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 25th, 2007, 3:14 PM   #11
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
This is what I mean more specifically[PHP]<?php
echo '<table>';
echo '<td>';
if(isset($_GET['foo'])){
// Process the form
echo 'Some updated database stuff';
echo '</td>';
echo '</table>';
echo '<a href="form.php">Add to table</a>';
}else{
echo 'Some old database stuff';
echo '</td>';
echo '</table>';
echo '<form method="post" action="form.php?foo=1">';
echo '<input type="submit" name="submit" value="Submit">';
echo '</form>';
}
?>[/PHP]
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Apr 25th, 2007, 4:23 PM   #12
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3 kruptof is on a distinguished road
By using the hidden value field, would it be possible for the user to manually change the false to a true? Enabling the user would be submit the same data twice.
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Apr 25th, 2007, 10:33 PM   #13
Styx
Programmer
 
Join Date: Mar 2007
Posts: 39
Rep Power: 0 Styx is on a distinguished road
I'm confused. How does that help? You submit the form action to ?foo=1 for initial processing, but you can still refresh and do it all over again.

Though, now that I think of it, you can use a header redirect after the form's been processed and they won't be able to hit refresh or click back to submit that same form. Though, that doesn't prevent them from navigating to the original form and filling it out again. You'd need to check something like cookies or ip or browser for that.
Styx is offline   Reply With Quote
Old Apr 25th, 2007, 11:21 PM   #14
tAK
Programmer
 
Join Date: Mar 2007
Posts: 33
Rep Power: 0 tAK is on a distinguished road
The best way to do it, is to check if the data already exists!

[PHP]<?php
if (isset($_POST['data']))
{
$data = $_POST['data'];
$mysql = mysql_query("SELECT * FROM table WHERE data='$data'");
if (mysql_fetch_numrows($mysql) >= 1)
{
// do some more if checks here to see if the data belongs to this user
// for editing or whatever else is needed to make it 100% verified
echo 'Data already exists';
} Else {
//do whatever needs doing to update the data.
}
}
?>[/PHP]

i have found that having 1 php page to create the form, and another page to handle the forms data works well.. usually along the lines of:
input.php <- contains code for the form
input_handler.php <- contains code to handle the form

also, the reason i set $data = $_POST['data'], is because i have a custom function that escapes all the information, prevents people from including their own PHP / SQL code in your input box and doing all sorts of nasty stuff
tAK is offline   Reply With Quote
Old Apr 26th, 2007, 12:27 AM   #15
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Quote:
I was wondering how to go about handling this issue so that if the user hits "Refresh" the script will not do anything.
As I understand the problem ssrun has not stipulated that the same data can't be uploaded. What he's asking for is purely to deal with situation of resubmitting the same info upon a refresh. He wants the program not to do anything after a submission of info.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Apr 26th, 2007, 3:10 AM   #16
Styx
Programmer
 
Join Date: Mar 2007
Posts: 39
Rep Power: 0 Styx is on a distinguished road
Yes, and doing your example doesn't help that =/ On the next page, even so it displays the Add to table link, you can still click refresh and resubmit the same info.
Styx is offline   Reply With Quote
Old Apr 26th, 2007, 12:57 PM   #17
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
It will work if he's using includes & other pages. Just a different way of thought. Like I said it depends on how he designs it. What we have to remember is that, essentially you can't really stop the user from entering the same data twice. There's always some way (switching computer, clearing cookies, altering form whatever) The task here was to stop the refresh. There are numerous ways to solve the problem, it's just a case of which will work best for him.
Booooze is offline   Reply With Quote
Old Apr 26th, 2007, 6:18 PM   #18
tAK
Programmer
 
Join Date: Mar 2007
Posts: 33
Rep Power: 0 tAK is on a distinguished road
i give up.

Go and get a system that does what you want, and see how it manages it.
phpBB is usually a good one to checkout, as it usually handles all of this stuff at some point.

if the data is being sent to a database, then check to see if it already exists..

Else, write the data to a cookie, and when the page gets loaded (whether refreshed or submitted to) check it to see if the data is in the cookie.. If it is, then the page is not what you want if it isn't, then you want it to go ahead.
tAK is offline   Reply With Quote
Old Apr 27th, 2007, 1:43 AM   #19
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
You're right Styx, I apologize for my previous post it was indeed mistaken. I was trying to emulate somethign I do on my own forum software and just realized that the reason it doesn't work is because I have an intermediate page that redirects to where I need to go. This does work, but you're right about pressing back on the browser and stuff:[php]<?php
if(isset($_GET['foo'])){
echo 'Some new database stuff';
echo '<a href="form.php">Update Records</a>';
}elseif(isset($_POST['foo'])){
// Process the form
echo '<html>';
echo '<head>';
echo '<meta http-equiv="refresh" content="0;url=form.php?foo=1">';
echo '</head>';
echo '<body>';
echo 'Redirecting';
echo '</body>';
echo '</html>';
}else{
echo 'Some old database stuff';
echo '<form method="post" action="form.php">';
echo '<input type="text" name="foo">';
echo '<input type="submit" name="submit" value="Submit">';
echo '</form>';
}
?>[/php]It uses a meta refresh rather than a header() function
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
FFT DWTIB -> Optimization -> Choosing An Appropriate Run Time Sane Software Design and Algorithms 7 Dec 1st, 2006 10:40 AM
Show or hiding forms/modifying control properties ..from different a form.. cloud- C# 4 Nov 10th, 2006 10:51 AM
Form Submit Blues MegaArcon Python 3 Dec 14th, 2005 4:20 PM
.NET Timer Form closing issue MBirchmeier C# 4 Nov 21st, 2005 10:00 AM
entering data into excel from a form glevine Perl 1 Nov 18th, 2005 5:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:04 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC