Refresh input text box with new string every 10 seconds

I’ve searched on here and other places as well and I can’t seem to find any previous posts that match what is below. Either that or I didn’t search hard enough…

What I’m trying to do: Everytime someone presses the submit button I want the <input type="text" name="comment_id" id="comment_id" value=""> to have a new random string (new id) so that way each time someone presses submit, the id is not a replica of the previous as I’m using such ID (not the automated ID by database) to identify these comments.

What I currently have:

<?php 
$length = 18;
$randomString = substr(str_shuffle("0123456789-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
?>

<input type="text" name="comment_id" id="comment_id" value="<?php echo $randomString;?>">

Gives me an 18 character string like this (BknmexSFAgP7pjsUIo).

To put it simply, what I want it to do is: every single time you press submit, a new id is generated inside the text box. I’ve tried using several methods but none seem to do the trick…

Thank you in advance for your help.

Try this:

Or use the phone time() function followed by the users $_SERVER['REMOTE_ADDR'];

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.