Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

Prevent Duplicate Form Submission

Learn how to use PHP sessions to prevent duplicate form submission or re-submission.

On Tuesday, June 27th 2006 at 11:42 AM
By Jatinder Thind (View Profile)
*****   (Rated 4.7 with 15 votes)
Contextual Ads
More PHP Resources
Advertisement

You can use the method below to prevent duplicate form submission or form re-submission using PHP. This method is simple to implement and does not require JavaScript.
I will assume that the form is in the form.php file and the form submission is being handled by the form-exec.php script.

Modifying your form

Add this PHP code to the top of the form.php script:

<?
session_start();
$secret=md5(uniqid(rand(), true));
$_SESSION['FORM_SECRET']=$secret;
?>

In the PHP code above we create a unique ID using the uniqid() function and then create a 32 character hash of this unique ID using md5() function. Next we store this unique ID in the session for later use in the form-exec.php script. Remember to use a different session variable for each form.
Then add a hidden field anywhere in your form:

<html>
<input type="hidden" name="form_secret" id="form_secret" value="<?php echo $_SESSION['FORM_SECRET'];?>" />
</html>


Handling form submission

Compare the value of the hidden field with the value stored in the session. If the values match, process the form data. After processing the form data unset the value stored in the session. Now if the user refreshes the page, the form processing code will be skipped. See the sample code below.

<?
//Retrieve the value of the hidden field
$form_secret=$_POST['form_secret'];
if(isset($_SESSION['FORM_SECRET'])) {
if(strcasecmp($form_secret,$_SESSION['FORM_SECRET'])===0) {
/*Put your form submission code here
After processing the form data,
unset the secret key from the session
*/

unset($_SESSION['FORM_SECRET']);
}else {
//Invalid secret key
}
}else {
//Secret key missing
echo 'Form data has already been processed!';
}
?>

Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this tutorial
Comment Current Comments
by Spudmonkey on Monday, July 10th 2006 at 01:38 PM

Won't this also prevent submission if the user takes too long to fill out the form (say more than 20 minutes, the default session timeout value)?

by Jatinder on Tuesday, July 11th 2006 at 07:58 AM

Yes, but that is is inherent in any script which uses sessions be it shopping carts or login modules.

by MURPHY on Saturday, August 19th 2006 at 11:30 AM

We are mobile phones wholesalers.We deals on all
brands and models of mobile phones such as
Nokia,Motorola,Samsung,Sony Ericsson,Sagem,
Nextel,Sidekick II,Sprint,Ipods, Laptops, Mp3 players
and many more at very cheap prices.We are using this
medium to look for serious buyers of mobile phones.Do
kindly reply back if you are interested and as you do you will be
glad during business with us.

Thank's and God bless in anticipation of your
patronage.

HERE IS SOME OF OUR PRICE LIST:

MOTOROLA RAZOR V3 AT JUST $140usd

NEXTEL i930 AT JUST $130usd

NEXTEL i860 AT JUST $110usd

SONY ERICSSON P910i AT JUST $160usd

SONY ERICSSON W800i AT JUST $160usd

SONY ERICSSON S700i AT JUST $145usd

MOTOROLA MPX 220 AT JUST $140usd

MOTOROLA MPX 300 AT JUST $180usd

SONY ERICSSON S700i AT JUST $140usd

SONY ERICSSON W800i AT JUST $160usd

NOKIA N92 AT JUST $240usd

NOKIA N80 AT JUST $200usd

NOKIA N70 AT JUST $180usd

MICROSOFT XBOX 360 AT JUST $140usd

PALM TREO 650 AT JUST $140usd

PALM TREO 700W AT JUST $160usd

PALM TREO 600 AT JUST $120usd

NOKIA 9500 AT JUST $210usd

NOKIA 9300 AT JUST $190usd

NOKIA 3250 AT JUST $200USD

NOKIA 6280 AT JUST $210USD

NOKIA N93 AT JUST $250USD

NOKIA N90 AT JUST $210usd

NOKIA N91 AT JUST $230usd

Nokia 8800 (unlocked) AT JUST $240usd

Nokia N71 (unlocked) AT JUST $210

Samsung D800 (unlocked) AT Just $150usd

Samsung SGH-D820 Quad AT JUST $120usd

Samsung SGH - E900 AT JUST $155usd

SAMSUNG D600 AT JUST $140usd,

SAMSUNG D500 AT JUST $130usd,

SAMSUNG D415 AT JUST $120usd

SIDEKICK II AT JUST $120usd,

iMate Jasjar............$250usd

iMate K-Jam................$170usd

iMate PDA2k...............$210usd

iMate Windows Mobile Pocket PC Phone .....$205usd

O2 Xda 2s ii ll Pda Phone........ $270

O2 Xda Atom Mobile Phone........ $260

O2 XDA II Mini Mobile Cellular Phone......$270

QTEK 9100 (Stylish black) PDA Phone (Sim Free /
Unlocked).....$240

Qtek S100 for $210

Qtek 8300......................$185

Qtek 8310 Smartphone (Worldwide, Unlocked).......$200

Qtek 9000..................$300

Qtek 9000 with Atlantis 11G Router........$350

Note that all our phones are brand new with complete accessories come with 1 year international warranty and 6month return policy incease of any damage before the specific period, also our minimum order qty is 10 units, so how many are you willing to buy?..reply back.

World Mobile Phones Inc.
Address:103 Clarendon Road,
City:LEEDS,
Zipcode:LS2 9DF,
Sate:West Yorkshire,
Country:United Kingdom.
Tel: +44(0)7024020862
Fax:+44(0)7005-931-434
email:worldmobilephones@europe.com
you can aswell visit our website for more details:
( www.worldmobilephones.8m.net )

MURPHY

by MURPHY on Saturday, August 19th 2006 at 11:36 AM

We are mobile phones wholesalers.We deals on all
brands and models of mobile phones such as
Nokia,Motorola,Samsung,Sony Ericsson,Sagem,
Nextel,Sidekick II,Sprint,Ipods, Laptops, Mp3 players
and many more at very cheap prices.We are using this
medium to look for serious buyers of mobile phones.Do
kindly reply back if you are interested and as you do you will be
glad during business with us.

Thank's and God bless in anticipation of your
patronage.

HERE IS SOME OF OUR PRICE LIST:

MOTOROLA RAZOR V3 AT JUST $140usd

NEXTEL i930 AT JUST $130usd

NEXTEL i860 AT JUST $110usd

SONY ERICSSON P910i AT JUST $160usd

SONY ERICSSON W800i AT JUST $160usd

SONY ERICSSON S700i AT JUST $145usd

MOTOROLA MPX 220 AT JUST $140usd

MOTOROLA MPX 300 AT JUST $180usd

SONY ERICSSON S700i AT JUST $140usd

SONY ERICSSON W800i AT JUST $160usd

NOKIA N92 AT JUST $240usd

NOKIA N80 AT JUST $200usd

NOKIA N70 AT JUST $180usd

MICROSOFT XBOX 360 AT JUST $140usd

PALM TREO 650 AT JUST $140usd

PALM TREO 700W AT JUST $160usd

PALM TREO 600 AT JUST $120usd

NOKIA 9500 AT JUST $210usd

NOKIA 9300 AT JUST $190usd

NOKIA 3250 AT JUST $200USD

NOKIA 6280 AT JUST $210USD

NOKIA N93 AT JUST $250USD

NOKIA N90 AT JUST $210usd

NOKIA N91 AT JUST $230usd

Nokia 8800 (unlocked) AT JUST $240usd

Nokia N71 (unlocked) AT JUST $210

Samsung D800 (unlocked) AT Just $150usd

Samsung SGH-D820 Quad AT JUST $120usd

Samsung SGH - E900 AT JUST $155usd

SAMSUNG D600 AT JUST $140usd,

SAMSUNG D500 AT JUST $130usd,

SAMSUNG D415 AT JUST $120usd

SIDEKICK II AT JUST $120usd,

iMate Jasjar............$250usd

iMate K-Jam................$170usd

iMate PDA2k...............$210usd

iMate Windows Mobile Pocket PC Phone .....$205usd

O2 Xda 2s ii ll Pda Phone........ $270

O2 Xda Atom Mobile Phone........ $260

O2 XDA II Mini Mobile Cellular Phone......$270

QTEK 9100 (Stylish black) PDA Phone (Sim Free /
Unlocked).....$240

Qtek S100 for $210

Qtek 8300......................$185

Qtek 8310 Smartphone (Worldwide, Unlocked).......$200

Qtek 9000..................$300

Qtek 9000 with Atlantis 11G Router........$350

Note that all our phones are brand new with complete accessories come with 1 year international warranty and 6month return policy incease of any damage before the specific period, also our minimum order qty is 10 units, so how many are you willing to buy?..reply back.

World Mobile Phones Inc.
Address:103 Clarendon Road,
City:LEEDS,
Zipcode:LS2 9DF,
Sate:West Yorkshire,
Country:United Kingdom.
Tel: +44(0)7024020862
Fax:+44(0)7005-931-434
email:worldmobilephones@europe.com
you can aswell visit our website for more details:
( www.worldmobilephones.8m.net )

MURPHY

by on Thursday, September 21st 2006 at 03:24 PM

Be very careful, This MURPHY is a FRAUD, the web site doesn´t exists, the phone and fax numbers are false !
He stoled my money.

by fabian on Friday, September 22nd 2006 at 10:56 PM

LETTER OF BUSINESS RELATIONSHIP
We are mobile phones wholesalers.We deals on all brands and models of mobile phones such as Nokia,Motorola,Samsung,Sony Ericsson,Sagem, Nextel,Sidekick II,Sprint,Ipods, Laptops, Mp3 players and many more at very cheap prices.We are using this medium to look for buyers of mobile phones.Do kindly reply back if you are interested and as you do you will be glad you do, you can reach us through our email addressaffordable_store@hotmail.com. thank's and God bless.


WE ARE SELLING ALL KIND OF MOBILE PHONES/LAPTOPS/GAMES AND IPODS SUCH AS:

PLAY STATION 3 AT JUST..... $120USD
SONY PSP AT JUST ................$100USD
MICROSOFT XBOX 360 AT JUST. $160USD

NOKIA 9500 AT JUST .................$195usd
NOKIA 8850 GOLD EDITION.............$120usd
NOKIA 9300 AT JUST .................$160usd
NOKIA N90 AT JUST ..................$130usd
NOKIA N91 AT JUST ..................$160usd
NOKIA N92 AT JUST ..................$200usd
NOKIA N93 AT JUST ..................$240usd

SONY ERICSSON P800(UNLOCK)..........$180usd
SONY ERICSSON P900(UNLOCK)..........$200usd
SONY ERICSSON P980i(UNLOCK).........$200usd
SONYERICSSON P990i JUST FOR ........$210USD
SONY ERICSSON W800i AT JUST ........$140usd
SONY ERICSSON S700i AT JUST ........$125usd
SONY ERICSSON Z800i AT JUST ........$240usd
SONY ERICSSON Z700i AT JUST ........$205usd

MOTOROLA V600.......................$120usd
MOTOROLA V3 RAZ JUST FOR............$140USD BLACK COLOR
MOTOROLA V3 RAZ JUST FOR............$150USD SILVER COLOR
MOTOROLA V3 RAZ JUST FOR............$160USD PINK COLOR
MOTOROLA MPX 220 AT JUST ...........$120usd
MOTOROLA MPX 300 AT JUST ...........$160usd

NEXTEL i930 AT JUST ................$110usd
NEXTEL i860 AT JUST ................$100usd
SAMSUNG D500 AT JUST ...............$160usd
SAMSUNG D415 AT JUST................$120usd
SAMSUNG SGH D720 JUST FOR ..........$170USD

QTEK
Qtek s100 =$200
Qtek 9090 =$210
Qtek 8020 =$200
Qtek 8010 =$180
Qtek 2020i=$240
Qtek 2020 =$250
Qtek 8080 =$130
Qtek 8060 =$160
Qtek 1010 =$150
Qtek 7070 =$250



IPODS
Apple 6 GB ipod mini green
m9807ll/a''''''''''''''''''''''''''''''''''us$64.00
New apple 60 GB video ipod'''''''''''''''''us$100.00
New apple 30 GB video ipod'''''''''''''''''us$80.00
New apple 80 GB Video ipod...........us$190.00

SIDE-KICK 2 AND 3
T-Mobile Sidekick II Cell Phone...............................$100
Mobile Sidekick II............................................$100
Mobile Sidekick III...........................................$150
Sidekick III Wood Look Skin & Screen Protector Brand New .....$160
Sidekick II Red Sparkle Skin/Screen Protector Cover New ......$170
Danger hiptop / T-Mobile Sidekick Universal FM Radio .........$190

BRAND NEW LAPTOPS
Dell Inspiron 6000 Laptop Computer......$300
Acer Aspire 3002LCi Laptop Computer.....$150
Toshiba Satellite R15-S822 Laptop Computer....$250
Toshiba Qosmio G15-AV501 Laptop Computer...$450
Dell Inspiron 1200 Laptop Computer.....$200
AVERATEC AV3220H1 Laptop Computer....$350
Apple PowerBook G4 Laptop Computer.....$400
Apple iBook M8861LL/A Laptop Computer...$150
Sony VAIO B100B Laptop Computer....$400
Sony VAIO S360 Laptop Computer...$500
Sony VAIO FS550 Laptop Computer...$300

Digital camera
Acer cs-5530 digital camera=$150
Canon ixus 700 digital camera= $200
Canon ixus 750 digital camera =$160
Canon ixus i zoom digital camera (jet black)=$210
Canon ixus i zoom digital camera (Sahara)=$200
Canon power shot s80 digital camera = $220
Casio exilim ex-s500 digital camera (orange, )= $230
Digital blue qx5 digital microscope= $170
Fuji film finepix f10 digital camera =$150
Nikon d2x digital camera (body only)=$140
Olympus fe-100 digital camera =$150


Interested buyer contact us direct by email (affordable_store@hotmail.com)


The best awards and adV specialties supplier on the Net
auctioning-Sidekick and Ipod
Regards
FABIAN
Telephone #........:+2348033838357
E_MAIL:affordable_store@hotmail.com
and many more available in store and legit buyer needed.

by Fazayal on Monday, February 26th 2007 at 02:20 AM

What ever it is but i use phprunner3.1 ... thats give me user friendly interface and wysiwyg interface ... i can create whatever very quickly..


fazayal
http://www.habinfotech.com

by bijoy on Monday, February 26th 2007 at 02:22 AM

<a herf="google.com">Google</a> - the best thing...go to google code search...

:D

by oi8uu on Friday, July 18th 2008 at 09:05 AM

fgfhgfgfjhgkjhk try

by Iohan on Monday, August 31st 2009 at 12:43 PM

Thanks for sharing!
http://online.promoters.ro

by greg on Monday, August 31st 2009 at 04:40 PM

http://bbqbomb.com

by Danny Mathew on Wednesday, May 26th 2010 at 08:00 AM

Check out UnlockGenie for unlocking your GSM phones at low prices

http://www.unlockgenie.com/

by ppp on Friday, August 20th 2010 at 05:54 PM

pp

by ppp on Friday, August 20th 2010 at 05:54 PM

pp

by ppp on Friday, August 20th 2010 at 05:54 PM

pp

by ppp on Friday, August 20th 2010 at 05:54 PM

pp


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Tutorials
There are no related tutorials.

Comment Related Source Code
There is no related source code.

Jobs PHP Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Sponsors
Discover Geekpedia

Other Resources