简体   繁体   中英

How would I prefill a form with a random number, and also allow the user to input their info? Im using html, php, and my sql

I'm taking an internet applications class, and I am coding a silent auction. My part is to make a form for the bidder to type in their information so they can bid. I already have the bidder form coded, but how would I make it so that the bidder form comes with a pre-filled, random bidding number? So basically when a bidder wants to bid, they get a form with a random number on it that they must fill this form out and submit back to the database. When the bidder sumbits their form, again the number is displayed. (Thank you 777 for you bid, remember this number).

You could do something simple like this:

// your PHP
$number = mt_rand(1, 5000);

// your form...
<input type="text" name="bidder_number" value="<?php echo $number; ?>" />

I would hope you're using more than just the number for verification, however, otherwise nothing will prevent other bidders from randomly guessing someone else's number.

You will also want to make sure the number/token is actually unique and hasn't already been assigned to someone else, so store all the numbers in a flat file or database and make the comparison there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM