PHP Verification Code $_post[]
In this circular statement, what is the function of seeking $num?
Because the imagestring () function works: Adds a number to the image. I think that $num is definitely used to limit the number of digits added to the image,
But change $num=4, $num =15 or other numbers, the image still shows 4 characters.
And I would like to ask weakly weak, through post and get pass parameters, such as login?id=2&value=3, this id,value through
$_post or $_get gets, the value of ID and value is an integer or a character!
Do not want to verify, too troublesome, on the Warrior advice!!!
Reply to discussion (solution)
The first question. Do you try $num=2 or four numbers?
$x calculation means only four digits are displayed
The second question I do not know whether it is a character or an integer expecting an expert to answer, but can be when the word trailing characters can also be used as an integer this is the charm of PHP
The first one to see upstairs.
A second string
Your picture width is fixed ...
Take a look at me again:
The first question. Do you try $num=2 or four numbers?
$x calculation means only four digits are displayed
The second question I do not know whether it is a character or an integer expecting an expert to answer, but can be when the word trailing characters can also be used as an integer this is the charm of PHP
Changes have changed after $num<4, but can you give me specific how to $x restrictions?
$x =rand (1,8) + $imagewidth * $i/4;
It's clear that you can adjust the writing order.
$x = $imagewidth/4 * $i + rand (1,8);
which
$imagewidth/4 Divide the width of the canvas into 4 points
$imagewidth/4 * $i The beginning of the first $i character on the canvas
Rand (1,8) lets the starting position be shifted to several points
When the number of characters exceeds 4, there is no limit, just the calculated position outside the canvas. Painted and painted in white.
$x =rand (1,8) + $imagewidth * $i/4;
It's clear that you can adjust the writing order.
$x = $imagewidth/4 * $i + rand (1,8);
which
$imagewidth/4 Divide the width of the canvas into 4 points
$imagewidth/4 * $i The beginning of the first $i character on the canvas
Rand (1,8) lets the starting position be shifted to several points
When the number of characters exceeds 4, there is no limit, just the calculated position outside the canvas. Painted and painted in white.
Seems to be a little understanding, with the question, if you want to generate random code containing letters and numbers, how should be rewritten?
I hope my eldest brother will advise
$x =rand (1,8) + $imagewidth * $i/4;
It's clear that you can adjust the writing order.
$x = $imagewidth/4 * $i + rand (1,8);
which
$imagewidth/4 Divide the width of the canvas into 4 points
$imagewidth/4 * $i The beginning of the first $i character on the canvas
Rand (1,8) lets the starting position be shifted to several points
When the number of characters exceeds 4, there is no limit, just the calculated position outside the canvas. Painted and painted in white.
Seems to be a little understanding, with the question, if you want to generate random code containing letters and numbers, how should be rewritten?
I hope my eldest brother will advise
Seriously, if you already understand this, then just take a look at some of Imagestring's parameters and you should understand that.
The fifth parameter of Imagestring () is to specify what to write
You start with a $str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
And then every time I randomly take a word out of it?
$str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for ($i =0; $i < $num; $i + +) { $x =rand (1,8) + $imagewidth * $i/4; $y =rand (1, $imageheight/4); $font = Imagecolorallocate ($im, Rand (100,255), Rand (0,100), Rand (100,255)); Generate random Colors $authnum =substr ($str, Rand (0,35), 1);//Select a $vcodes randomly from 10 numbers + 26 letters . = $authnum;
The first question. Do you try $num=2 or four numbers?
$x calculation means only four digits are displayed
The second question I do not know whether it is a character or an integer expecting an expert to answer, but can be when the word trailing characters can also be used as an integer this is the charm of PHP
Just on behalf of the people of the world thank you for a moment ... , give points immediately!!