Login verbessern mit AJAX/PHP?

Ich habe ein Login gebaut. Jenen sollen wir nun ausschließlich mit AJAX verbessern. (Wir dürfen dabei nicht sowas wie JQUERY verwenden. Das wissen fehlt uns aber dafür an meisten. Vielleicht kann jemand mir dabei helfen mein Login umzubauen und zu verstehen was ich mache.

Mein Login-Quelltext:

<?php
$pdo = new PDO('mysql:host=localhost;dbname=phptest', 'root', '');

if(isset($_GET['login'])) {
  $email = $_POST['Email'];
  $passwort = $_POST['Passwort'];

  $statement = $pdo->prepare("SELECT * FROM login WHERE Email = :Email");
  $result = $statement->execute(array('Email' => $email));
  $user = $statement->fetch();

  //Überprüfung des Passworts
  if ($user !== false && password_verify($passwort, $user['Passwort'])) {
    $_SESSION['userid'] = $user['ID'];
    die('Login erfolgreich. Weiter zu <a href="index.php?site=Startseite">internen Bereich</a>');
  } else {
    $errorMessage = "E-Mail oder Passwort war ungültig<br>";
  }

}
?>
<!DOCTYPE html>
<html>
<head>
  <title>Login</title>
</head>
<body>

<?php
if(isset($errorMessage)) {
  echo $errorMessage;
}
?>

<form action="Loginseite.php?login=1" method="post">
  E-Mail:<br>
  <input type="email" size="40" maxlength="250" name="Email" required><br><br>

  Dein Passwort:<br>
  <input type="password" size="40" maxlength="250" name="Passwort" required><br>

  <input type="submit" value="Login">
</form>
</body>
</html>
Computer, HTML, programmieren, JavaScript, AJAX, PHP, Webdesign
C++: multiple definition...?

Hallo, ich habe in C++ einen Header erstellt, aber bei der Complierung kommt immer diese Fehlermeldung:

C:\Users\Admin\AppData\Local\Temp\ccdaLGOT.o:lexer.cpp:(.text+0x111): undefined reference to `Token::content[abi:cxx11]() const'
...(Zu lang zum abschicken)
collect2.exe: error: ld returned 1 exit status

Kann mir jemand sagen was der Fehler ist und wie ich ihn behebe?

token.hpp:

#ifndef TOKEN_HPP_
#define TOKEN_HPP_

#include <string>

class Token {
public:
    enum class Type {
        STRING,
        NUMBER,
        BOOLEAN,
        IDENTIFIER,
        EQUAL,
        PLUS,
        MINUS,
        TIMES,
        DIVIDE,
        LESS_THAN,
        GREATER_THAN,
        COMMENT,
        DOT,
        COMMA,
        SEMICOLON,
        CURLY_BRACKET_RIGHT,
        CURLY_BRACKET_LEFT,
        APOSTROPHE,
        COLON,
        UNEXPECTED
    };

    Token                (Type type)              noexcept;

    Type type            ()                       const noexcept;

    bool is                (Type type)               const noexcept;

    bool is_not            (Type type)               const noexcept;

    std::string content ()                       const noexcept;

    void change_content (std::string content)  const noexcept;

    void add_to_content (std::string content)  const noexcept;

    void clear_content  ()                       const noexcept;

    void change_type    (Type type)            const noexcept;

private:
    Type m_type;
    std::string m_content;
};

#endif

token.cpp:

#include "token.hpp"

#include <string>

Token::Token(Type type) noexcept : m_type{type} {};

Token::Type Token::type() const noexcept {
    return m_type;
}

bool Token::is(Type type) const noexcept {
    return m_type == type;
}

bool Token::is_not(Type type) const noexcept {
    return m_type != type;
}

std::string Token::content() const noexcept {
    return m_content;
}

void Token::change_content(std::string content) const noexcept {
    m_content = content;
}

void Token::add_to_content(std::string content) const noexcept {
    m_content = m_content + content;
}

void Token::clear_content() const noexcept {
    m_content.clear(); //Die clear Funktion geht auch nicht
}

void Token::change_type(Type type) const noexcept {
    m_type = type;
}

Ich hoffe jemand kann mir dabei helfen!

LG

PC, Computer, Software, programmieren, compiler, Cplusplus, CPP, development, Informatik, Informatiker, Programmiersprache, C (Programmiersprache), Cpp Programierung
SwiftUI Search Bar mit Liste?

Ich möchte für meine Liste eine SearchBar implementieren, was ursprünglich auch funktioniert hat, allerdings habe ich ein paar Sachen umgeschrieben und jetzt funktioniert es nicht mehr.

Warum und wie behebe ich es?

struct Elementis: Identifiable{
    var id = UUID()
    var order: String
    var ename: String   
}
let Chemics = [
    Elementis(order: "1", ename: "Wasserstoff"),
    Elementis(order: "2", ename: "Helium"),
    Elementis(order: "3", ename: "Lithium"),
    Elementis(order: "4", ename: "Beryllium"),
    Elementis(order: "5", ename: "Bor"),
]
import SwiftUI

    @State private var searchText = ""
    var Element: [Elementis] = Chemics

 var body: some View{
   List{
                ForEach(Element) { elementis in
                    HStack{
                        NavigationLink(elementis.ename,
                                       destination: Aluminium())
                        
                        //Text(elementis.order)
                    }
                }
           
                
            }
            .navigationTitle("Chemie")
            .searchable(text: $searchText, prompt: "Element suchen...")



}

 var searchResults: [String] {
           if searchText.isEmpty {
               return Element.ename
           } else {
               return Element.ename.filter { $0.contains(searchText) }
           }
       }
}

 

Es kann sein, dass einige Klammern hier auf GuteFrage fehlen, diese sind aber im Programm definitiv drin.

Der Fehler taucht unter "var searchResults" auf und sagt mir je nachdem was ich einsetze verschiedene Meldungen an.

Meistens sind es folgende Meldungen:

"Cannot convert return expression of type 'String' to return type '[String]' "

"Value of type '[Elementis]' has no member 'ename' "

Über ein wenig Hilfe würde ich mich freuen. Besten Dank im Voraus

PC, Computer, Internet, programmieren, Swift, SwiftUI
JS ARRAYS + RECHNEN?

Also ich habe ein Programm wo man per Knopfdruck über einen Prompt etwas schreiben kann und das steht dann im Array, aber es soll so sein das wenn man auf einen anderen Button drückt ein Allert kommt in dem steht wie viel alles zusammen ist also ich möchte es + rechnen.

Falls es hilfreich ist hier mein Code:

<html>

<head>

  <meta charset="utf-8" />

</head>

<body>

  <h1>Stromverbrauch</h1>

  <button onclick="addNewItem(); updateList();">Neuen Verbrauch hinzufügen</button>

  <ul id="list">

  </ul>

  <script>

    let shoppingItems = getShoppingItemsFromLocalStorage();

    updateList();

    function getShoppingItemsFromLocalStorage() {

      let items = localStorage.getItem('shoppingItems');

      if (items == null || items == '') {

        items = [];

      } else {

        items = items.split(',');

      }

      return items;

    }

    function addNewItem() {

      let item = prompt('Welchen Verbrauch hast du?');

      if (item != null) {

        shoppingItems.push(item);

        localStorage.setItem('shoppingItems', shoppingItems);

      }

    }

    function removeItem(itemIndex) {

      shoppingItems.splice(itemIndex, 1);

      localStorage.setItem('shoppingItems', shoppingItems);

    }

    function updateList() {

      document.getElementById('list').innerHTML = '';

      for (let index = 0; index < shoppingItems.length; index += 1) {

        document.getElementById('list').innerHTML += '<li>' + shoppingItems[index] +

        ' <button onclick="removeItem(' + index + '); updateList();">X</button></li>';

      }

    }

  </script>

</body>

</html>

Computer, programmieren, JavaScript, Informatik

Meistgelesene Beiträge zum Thema Programmieren