Jump to content

Recommended Posts

I'm doing this activity where a user chooses a base timezone and when the user clicks convert the current time in the selected GMT will be converted to GMT-11 to GMT+13.

 

As of now, I have these codes:

act09_view.php:

<?php
session_start();
    
    $s="GMT ";
    echo "Select the base time zone:</br>";
   
    for($n=-11;$n<=13;$n++)
    {
        if ($n>=0)
            $s="GMT +";
        $gmt[]=$s . $n . "</br>";
    }

    echo "<select name='gmt'>";
    foreach ($gmt as $value) 
    {
        echo '<option value="' . $value . '">' . $value . '</option>\n';
    } 
    echo '</select>';
    //$_SESSION['value']=$value;
?>
<form action="act09_process.php">
       </br><input type='submit' value='Convert'/>
</form>

 

act09_process.php:

<?php
session_start();
//$value=$_SESSION['value'];
//echo $value;

date_default_timezone_set('Asia/Manila');
$gmttime=date('M j, Y g:i:s A');
echo "The current date and time at" . " is " . $gmttime;
?>

 

I've tried using session variables. I think I executed them incorrectly.  :confused:

 

The output is supposed to look like this:

21l72j9.png

Drop-down lists are like any other form elements. Alike so:

 

<form method="POST" action="posthandler.php">
<select name="gmt"><option value="...">...</option></select>
<input type="submit" />
</form>

 

and in posthandler.php:

 

<?php
echo $_POST['gmt'];
?>

 

 

It seems that in your case, all you need to do is to move the <select> element inside your <form>, and possibly add action="POST" to the <form> also.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.