<?php
function sql($query)
{
  $link = mysql_pconnect("mysql.nehlsen.se", "motion", "alskling")
    or die("Could not connect");
  mysql_select_db("motion")
    or die("Could not select database");
  // Performing SQL query
  $result = mysql_query($query)
    or die("Query $query failed");
  return $result;
}
function datum($tid)
{
  $wdays=array("S&ouml;n", "M&aring;n", "Tis", "Ons", "Tors", "Fre", "L&ouml;r");
  $manad=array("Jan", "Feb", "Mar", "April", "Maj", "Juni", "Juli", "Aug",
               "Sep", "Oct", "Nov", "Dec");
  $tidennu=strtotime("-" . $tid . " day");
  $deltiden=getdate($tidennu);
  $tiden['dag']=$wdays[$deltiden['wday']] . " " . $deltiden['mday'] . " " .
                $manad[$deltiden['mon']-1] . " " . $deltiden['year'];
  $tiden['tid']=$tidennu;
  return ($tiden);
}
if ( isset($_POST['Submit']) )
{
sql(addslashes("insert into steg values(" . $_POST['users'] . ", " . $_POST['steg'] . ", FROM_UNIXTIME(" . $_POST['datum'] . "))"));
header("location: stegraknare2.php");
//echo $_POST['datum'];
//echo $_POST['users'];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.style1 {font-family: Georgia, "Times New Roman", Times, serif}
-->
</style></head>

<body>
  <form name="form1" method="post" action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>">
    <div id="ange" style="position:absolute; left:43px; top:218px; width:740px; height:192px; z-index:4">
      <table width="675" border="0" cellpadding="0" cellspacing="20">
	<tr>
	  <td><img src="hemsida/namnwebb.gif" width="86" height="41"></td>
	  <td><img src="hemsida/datumwebb.gif" width="88" height="45"></td>
	</tr>
	<tr>
	  <td><select name="users">
	      <?php
		 $result=sql("select * from users");
		 while ( $temp=mysql_fetch_assoc($result) )
		 {
		   echo "<option value='" . $temp['id'] . "'>" . $temp['name'] . "</option>";
		 }
		 ?>
	  </select></td>
	  <td><select name="datum">
              <?php
	      foreach ( array(0,1,2,3,4,5,6,7,8,9,10,11,12,13) as $temp)
	      {
	        $tid=datum($temp);
	        echo "<option value='" . $tid['tid'] . "'>" . $tid['dag'] . "</option>";
	      }	 
	      ?>
	    </select>
          </td>
	</tr>
      </table>
    </div>
    <div id="rubrik" style="position:absolute; left:64px; top:38px; width:652px; height:86px; z-index:5"><img src="hemsida/vargodwebb.gif" width="292" height="110"></div>
    <div id="antalsteg" style="position:absolute; left:616px; top:218px; width:296px; height:260px; z-index:7">
      <table width="283" border="0" cellspacing="20">
	<tr>
	  <td><img src="hemsida/antalstegwebb.gif" width="138" height="54"></td>
	</tr>
	<tr>
	  <td>
            <input size=5 lenght=5 type="text" name="steg">
            <input type="submit" name="Submit" value="Ok!">
	  </td>
	</tr>
      </table>
    </div>
  </form>
  <div id="direkt" style="position:absolute; left:61px; top:440px; width:111px; height:44px; z-index:9"><a href="stegraknare2.php"><img src="hemsida/direkttillwebb.gif" width="297" height="101" border="0"></a></div>
</body>
</html>
