xplody
xplody

Reputation: 103

How to combine post and session value

I was wondering is how to combine a (session) and (post) value to make a (title)value.

$position = $_POST['position'];
$division = $_POST['division'];
$title = $_SESSION['repcode'] +._.+ $_POST['position'];

I want is the outcome of the title would be

example output:

title = rep230_manager

how to do this?

Upvotes: 0

Views: 74

Answers (4)

Fred Willmore
Fred Willmore

Reputation: 4604

You can also interpolate the variable values into the string if you find that easier

$title = "{$_SESSION['repcode']}_{$_POST['position']}";

Upvotes: 1

Grish
Grish

Reputation: 862

To concatenate string in PHP use . operator

$title = $_SESSION['repcode'] .'_'. $_POST['position'];

Also you can use " " or ' ' for concatenating. But ' ' will be few nanoseconds faster than " " as Double quotes execute the string but single quote doesn't so its faster.

Upvotes: 1

Ian P
Ian P

Reputation: 12993

$title = $_SESSION['repcode'] . "_" . $_POST['position'];

Upvotes: 1

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

$title = $_SESSION['repcode'].'_'. $_POST['position'];

Upvotes: 3

Related Questions