norixxx
norixxx

Reputation: 3199

PHP SESSION array ends up in error

Quick PHP Question. I am kinda newb to PHP so bear with me.

Why this ends up with 500 server error?

<?php
//session start
session_start();

//one time ticket is issued
$ticket = md5(uniqid(mt_rand),TRUE);

//put var ticket in SESSION array which is used in next page.
$_SESSION['ticket'][] = $ticket;

...

$_SESSION['ticketPOST'] = $_POST['ticket'];

...

//functionize htmlspecialchars
function h($string) {
    return htmlspecialchars($string, ENT_QUOTES);
}

?>

in same file down below, I wrote something like this:

<form action="brahbrah.php" method="post">
<input type="hidden" name="ticket" value="<?php echo h($ticket); ?>">
<input type="submit" name="indexForm" value="preview">
</form>

any help appreciated. Thanx.

Upvotes: 0

Views: 212

Answers (3)

Kichu
Kichu

Reputation: 3267

See this link :http://php.net/manual/en/function.mt-rand.php

Try this code:

<?php
//session start
session_start();

//one time ticket is issued
$ticket = md5(uniqid(mt_rand()),TRUE);

//put var ticket to SESSION array which is used in next page.
$_SESSION['ticket'][] = $ticket;

...
?>

mt_rand required ()

Upvotes: 1

MrSil
MrSil

Reputation: 618

Set
error_reporting(E_ALL);
ini_set('display_errors', true);

And see what an error

Upvotes: 0

Mihai Matei
Mihai Matei

Reputation: 24276

$ticket = md5(uniqid(mt_rand()),TRUE);

mt_rand is a function and you forgot to put ()

Upvotes: 7

Related Questions