From 7cd04e2a52a25208236f8a8ebe6b5280f5ad2ee5 Mon Sep 17 00:00:00 2001 From: max Date: Tue, 15 Apr 2025 20:29:16 +0200 Subject: [PATCH] init --- .idea/.gitignore | 8 +++ .idea/Web_Rippchen.iml | 8 +++ .idea/modules.xml | 8 +++ .idea/php.xml | 19 ++++++ .idea/vcs.xml | 6 ++ add_restaurant.php | 46 ++++++++++++++ add_review.php | 70 +++++++++++++++++++++ central.css | 136 +++++++++++++++++++++++++++++++++++++++++ db_connection.php | 16 +++++ index.php | 13 ++++ login.php | 52 ++++++++++++++++ logout.php | 6 ++ register.php | 55 +++++++++++++++++ 13 files changed, 443 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Web_Rippchen.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 add_restaurant.php create mode 100644 add_review.php create mode 100644 central.css create mode 100644 db_connection.php create mode 100644 index.php create mode 100644 login.php create mode 100644 logout.php create mode 100644 register.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Web_Rippchen.iml b/.idea/Web_Rippchen.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/Web_Rippchen.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c6404b8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/add_restaurant.php b/add_restaurant.php new file mode 100644 index 0000000..60217f1 --- /dev/null +++ b/add_restaurant.php @@ -0,0 +1,46 @@ +query($sql) === TRUE) { + $restaurant_success = "Restaurant added successfully!"; + } else { + $restaurant_error = "Error: " . $sql . "
" . $conn->error; + } +} + +$conn->close(); +?> + + + + + Add Restaurant + + +

Add New Restaurant

+ +

+ + +

+ +
"> + Name:

+ Maps Link:

+ +
+

Back to Dashboard

+ + \ No newline at end of file diff --git a/add_review.php b/add_review.php new file mode 100644 index 0000000..600ca5a --- /dev/null +++ b/add_review.php @@ -0,0 +1,70 @@ + 10) { + $review_error = "Rating must be between 0 and 10."; + } else { + $sql = "INSERT INTO Bewertung (fk_user_id, fk_restaurant_id, bewertung, bewertung_str) VALUES ($fk_user_id, $fk_restaurant_id, $bewertung_int, '$bewertung_str')"; + + if ($conn->query($sql) === TRUE) { + $review_success = "Review added successfully!"; + } else { + $review_error = "Error: " . $sql . "
" . $conn->error; + } + } +} + +// Fetch restaurants for the dropdown +$restaurants_sql = "SELECT id, name FROM Restaurant"; +$restaurants_result = $conn->query($restaurants_sql); +$restaurants = []; +if ($restaurants_result->num_rows > 0) { + while ($row = $restaurants_result->fetch_assoc()) { + $restaurants[$row['id']] = $row['name']; + } +} + +$conn->close(); +?> + + + + + Add Review + + +

Add New Review

+ +

+ + +

+ +
"> + Restaurant: +

+ Rating (0-10):

+ Review Text:

+ +
+

Back to Dashboard

+ + \ No newline at end of file diff --git a/central.css b/central.css new file mode 100644 index 0000000..7b8c026 --- /dev/null +++ b/central.css @@ -0,0 +1,136 @@ +/* central.css */ + +/* General Styles */ +body { + font-family: sans-serif; + margin: 20px; + background-color: #f4f4f4; + color: #333; +} + +h1, h2, h3 { + color: #337ab7; +} + +a { + color: #337ab7; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +p { + line-height: 1.6; + margin-bottom: 15px; +} + +/* Form Styles */ +form { + background-color: #fff; + padding: 20px; + border: 1px solid #ddd; + border-radius: 5px; + margin-bottom: 20px; +} + +label { + display: block; + margin-bottom: 5px; + font-weight: bold; +} + +input[type="text"], +input[type="password"], +input[type="number"], +select, +textarea { + width: calc(100% - 12px); /* Adjust for padding */ + padding: 8px; + margin-bottom: 10px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; /* Ensure padding and border are inside the element's total width and height */ + font-size: 1em; +} + +input[type="submit"] { + background-color: #5cb85c; + color: white; + padding: 10px 15px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 1em; +} + +input[type="submit"]:hover { + background-color: #4cae4c; +} + +.error { + color: red; + margin-bottom: 10px; +} + +.success { + color: green; + margin-bottom: 10px; +} + +/* Navigation Styles (if you add a navigation later) */ +nav ul { + list-style: none; + padding: 0; + margin: 0; + background-color: #333; + overflow: hidden; + border-radius: 5px; + margin-bottom: 20px; +} + +nav ul li { + float: left; +} + +nav ul li a { + display: block; + color: white; + text-align: center; + padding: 14px 16px; + text-decoration: none; +} + +nav ul li a:hover { + background-color: #111; +} + +/* Table Styles (if you display data in tables) */ +table { + width: 100%; + border-collapse: collapse; + margin-bottom: 20px; + border: 1px solid #ddd; +} + +th, td { + border: 1px solid #ddd; + padding: 8px; + text-align: left; +} + +th { + background-color: #f2f2f2; + font-weight: bold; +} + +/* Specific elements for your pages */ +/* You can add more specific styles here as needed */ + +/* Example for the welcome message on index.php */ +.welcome-message { + margin-bottom: 20px; + font-size: 1.2em; + font-weight: bold; +} \ No newline at end of file diff --git a/db_connection.php b/db_connection.php new file mode 100644 index 0000000..462aa68 --- /dev/null +++ b/db_connection.php @@ -0,0 +1,16 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + die("Database connection failed: " . $e->getMessage()); +} + +// Function to sanitize user input (remains the same) +function sanitize_input($data) { + $data = trim($data); + $data = stripslashes($data); + return htmlspecialchars($data); +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..cf1bc2a --- /dev/null +++ b/index.php @@ -0,0 +1,13 @@ +Add Restaurant

"; +echo "

Add Review

"; +echo "

Logout

"; +?> \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..d976c63 --- /dev/null +++ b/login.php @@ -0,0 +1,52 @@ +query($sql); + + if ($result->num_rows == 1) { + $row = $result->fetch_assoc(); + if (password_verify($password, $row['password'])) { + $_SESSION['username'] = $row['username']; + $_SESSION['user_id'] = $row['id']; + header("Location: index.php"); // Redirect after successful login + exit(); + } else { + $login_error = "Invalid username or password."; + } + } else { + $login_error = "Invalid username or password."; + } +} + +$conn->close(); +?> + + + + + Login + + +

Login

+ +

+ +
"> + Username:

+ Password:

+ +
+

Don't have an account? Register here

+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..f359438 --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/register.php b/register.php new file mode 100644 index 0000000..694e270 --- /dev/null +++ b/register.php @@ -0,0 +1,55 @@ +query($check_sql); + + if ($check_result->num_rows > 0) { + $registration_error = "Username already exists. Please choose a different one."; + } else { + $sql = "INSERT INTO User (vorname, nachname, username, password) VALUES ('$vorname', '$nachname', '$username', '$hashed_password')"; + + if ($conn->query($sql) === TRUE) { + $registration_success = "Registration successful! You can now login."; + } else { + $registration_error = "Error: " . $sql . "
" . $conn->error; + } + } +} + +$conn->close(); +?> + + + + + Register + + +

Register

+ +

+ + +

+ +
"> + Vorname:

+ Nachname:

+ Username:

+ Password:

+ +
+

Already have an account? Login here

+ + \ No newline at end of file