![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
King of Portal
|
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 |
|
|
|
|
|
#12 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
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:
|
|
|
|
|
|
|
#13 |
|
Programmer
Join Date: Mar 2007
Posts: 39
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#14 |
|
Programmer
Join Date: Mar 2007
Posts: 33
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#15 | |
|
King of Portal
|
Quote:
__________________
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 |
|
|
|
|
|
|
#16 |
|
Programmer
Join Date: Mar 2007
Posts: 39
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#17 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#18 |
|
Programmer
Join Date: Mar 2007
Posts: 33
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#19 |
|
King of Portal
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |