Example #1
0
 /**
  *
  */
 function output_form()
 {
     $str = "";
     //get data
     $data_enc = get_da_from_db($this->datatype, $this->tablename, "{$this->pk} = {$this->rowid}", true);
     //usermessage
     if (isset($this->user_message)) {
         $str .= html_escape($this->user_message) . "<br><br>";
     }
     //form
     $str .= "<form method=\"post\" >\n";
     //form data
     $str .= "\t<table>\n";
     foreach ($this->datatype as $name => $type) {
         if ($type === "pk") {
             continue;
         }
         $str .= "\t\t<tr>\n";
         $str .= "\t\t\t<td>\n";
         $str .= "\t\t\t" . $name . ":\n";
         $str .= "\t\t\t</td>\n";
         $str .= "\t\t\t<td>\n";
         //input form and value
         if ($type === "int_bool") {
             $checked = $data_enc[$name] === "1" ? "checked" : "";
             $str .= "\t\t\t\t<input name=\"{$name}\" type=\"checkbox\"\t{$checked} >\n";
         } else {
             $value = $data_enc[$name];
             $str .= "\t\t\t\t<input name=\"{$name}\" type=\"text\"\tvalue=\"{$value}\" >\n";
         }
         $str .= "\t\t\t</td>\n";
         $str .= "\t\t</tr>\n";
     }
     $str .= "\t</table>\n";
     //buttons
     $str .= "\t<button name=\"submit\"\ttype=\"submit\"\tvalue=\"ok\"\t>Ok</button>\n";
     $str .= "\t<button name=\"submit\"\ttype=\"submit\"\tvalue=\"save\"\t>Gem</button>\n";
     $str .= "</form>\n";
     //return
     echo $str;
 }
Example #2
0
//handle
evt_handle_submit();
function evt_handle_submit()
{
    global $user_message, $mid, $datatype;
    if (isset($_POST['navn'])) {
        //get all
        $data = get_da_from_post($datatype);
        //saving the record
        update_da_in_db($data, $datatype, "medlemmer", "id = {$mid}");
        //the data was changed successful
        $user_message = "Dine informationer er gemt.";
    }
}
//henter nuværende data
$data_enc = get_da_from_db($datatype, "medlemmer", "id = {$mid}", true);
$nyhedsbrev_checked = $data_enc['nyhedsbrev'] === "1" ? "checked" : "";
$start_dato = db()->get_single_value("SELECT date(created) FROM medlemmer WHERE id = {$mid}");
?>
<!DOCTYPE html>
<html>
	<?php 
echo get_html_head();
?>
	<body>
	
		<div class="container">
				
			<?php 
echo get_body_header("user_profile");
?>