$statement = savePost2Database($title, $content); showModalNotification("Post saved!", "New post has saved with post id: {$statement}"); } elseif (POST('submit') == 'login') { $username = $_POST['username']; $password = $_POST['password']; $statement = getEncryptedPassword($username); $encryptedPassword = ""; $o = $statement->fetchObject(); if ($o) { $encryptedPassword = $o->password; } if (strtoupper(md5($password)) == $encryptedPassword) { $_SESSION['login'] = true; // $title = POST("title"); // $content = POST("content"); // global $title, $content; $statement = savePost2Database($_SESSION['title'], $_SESSION['content']); echo "<h3>Login success, saved!</h3>"; // showModalNotification("Login succes", "Welcome $username comes back!", "loginSuccess"); // showModalNotification("Post saved!", "New post has saved with post id: $statement", "savePostSuccess"); } else { $_SESSION['login'] = false; showModalNotification("Login failed", "Please login again"); } } else { showModalSessionLoginFalse("Action"); //showModalWhenEdit("myModal"); ?> <?php }
if ($submitType == 'login') { $username = $_POST['username']; $password = $_POST['password']; $statement = getEncryptedPassword($username); $encryptedPassword = ""; $databaseInfo = $statement->fetchObject(); if ($databaseInfo) { $encryptedPassword = $databaseInfo->password; } if (strtoupper(md5($password)) == $encryptedPassword) { $_SESSION['login'] = true; //save post // savePost(); } else { //show modal login failed!, login again showModalNotification("Login failed!", "Please try again!"); showModalSessionLoginFalse(); } } } else { echo "session false|"; showModalSessionLoginFalse(); } ?> <?php function savePost() { submitAJAX("create-post-form"); // $title = $_POST['title']; // echo $title;