开发者

How do I place a unique ID in my PHP confirmation page?

I have a PHP script that emails me the results from a form that generates a unique ID number. The PHP script executes a confirmation page. I'm trying to place the unique ID on the confirmation page: quote_confirm.php. I already tried this in the conformation page:

 <?php
    $prefix = 'LPFQ';
    $uniqid = $prefix . uniqid();
    $QuoteID = strtoupper($uniqid); 
    ."<开发者_运维问答tr><td class=\"label\"><strong>Quote ID:</strong></td><td>".$QuoteID."</td></tr>\n"


First off, uniqid() has a prefix parameter, so your line $uniqid = $prefix . uniqid(); should actually be $uniqid = uniqid($prefix);

Also, are you receiving an error? What is the output?


From what I can understand it is something like this:

form -> mail + output page

So there is mail()-like function and after that some output.

If the variable($uniqid) is set you have to make sure it's not overwritten or unset by something else before the actual output. You have to also check the scope of variable.

There is no mistake in the code you posted.

But speaking of style:

I also recommend using using $uniqid = uniqid($prefix) instead of $uniqid = $prefix. uniqid();. And the following line is strange:

."<tr><td class=\"label\"><strong>Quote ID:</strong></td><td>".$QuoteID."</td></tr>\n"

Write it as "<tr><td class=\"label\"><strong>Quote ID:</strong></td><td>$QuoteID</td></tr>\n" (if you insist on using "") and if the function is echo (example: echo $something not $content .= $something) use , instead of . .

Full example:

echo 'Constant text without variables', $variable, "String with a $variable and a newline \n";

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜