0

I'm trying to get a clients information on their computer and automatically using that to determine some components of the form. This form is ranging from the users name-location and I'm trying to make it so that the setup process is quick and easy. I'm also wondering if I can take information from cookies on previously saved websites? Here is the visible part of the html form I have so far.

     <td><input type="text" class="username" id="username" name="username" maxlength="45" size="30" value = "" /></td>
<td>E-Mail</td>
     <td><input type="text" name="email" size="30" value="" maxlength="100"/></td>


     <td>Password (between 6 and 16 chars):</td>
     <td valign="top"><input class="password" id="password" type="password" name="password"
         size="16" maxlength="16"/></td>

     <td>Confirm password</td>
     <td><input type="password" name="passwd2" size="16" maxlength="16"/></td>

   <tr>
     <td>Time Zone: </td>
     <td><select id="tzone" name="tzone" >
        <option value="Pacific/Midway" >(GMT-11:00) Midway Island, Samoa</option>
<option value="Pacific/Honolulu" >(GMT-10:00) Hawaii</option>
<option value="America/Anchorage" >(GMT-09:00) Alaska</option>

etc...
  </select>
    </td>

All I need is PHP to automate some parts of this form, such as the timezone, and make is easier for the user (I already know how to get the persons timezone, it's just I'm not able to use that in the <option select>.

4

1 回答 1

0

这可能会对您有所帮助。

带有 GET 表单或 POST 的 HTML

<select id="tzone" name="tzone" >
<option value="-:11" >(GMT-11:00) Midway Island, Samoa</option>
<option value="-:10" >(GMT-10:00) Hawaii</option>
<option value="-:09" >(GMT-09:00) Alaska</option>
<option value="+:04" >(GMT+04:00) Russia</option>
</select>

PHP

$selected_zone = $_GET["tzone"];// for POST use $_POST["tzone"]
$zone = explode(":", $selected_zone);
$timestamp = date("H:i:s");
if($zone[0] == "-" ){
    $time = date( "H:i:s", strtotime( $timestamp ) - $zone[1] * 3600 );
}else{
    $time = date( "H:i:s", strtotime( $timestamp ) + $zone[1] * 3600 );
}

并且会像这样放出时间

15:00:00

于 2013-03-26T05:48:30.307 回答