If you want to pass it to the PHP script (and later save it as a global or in a database) you could use cookies, or submit it as part of a form (what I'd suggest).
So you have
<form action="form_receiver.php" method="get">
Which basically means, submit all the (named) fields in this form to the form_receiver
page. The "get" could be replaced by "post" and they are just two methods for sending data ("get" data is encoded in the URL so it can be saved, useful for simple things, and "post" is "sent hidden by the browser" so is better for things like large ammounts of data or confidential stuff).
Now for the data in each field to be sent, you need to give it a name, as you have provided. So for that input field, you would only need to enclose it in a form.
On form_reciever.php
, you would be able to access the variables by name using $_GET['name']
or $_POST['name']
depending on which method you used. You could then save it somewhere else to use later.
Cookies should be for preserving data about the user (such as a session id), and I would not recommend using them to pass data between pages. However, if for some reason you require this, you could set cookie data with javascript and get it using $_COOKIE['cookie_name']
in php. If you're setting a cookie in php use setcookie("name", "value")
(more details here http://php.net/manual/en/function.setcookie.php).
There are many ways to set cookies in javascript. I would recommend using a library like jQuery and you could set and get cookies in a similar way: $.cookie("name", "new_value")
or $.cookie("name")
to get the value.