<div class="wrapper">
<form action="" method="post">
<div class="login-header">
<header>Sign Up</header>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-user input-icon"></i>
<select name="user-type" class="input-field">
<option value="" disabled selected>Select your role</option>
<option value="student">Student</option>
<option value="professor">Professor</option>
<option value="faculty">Faculty</option>
</select>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-user input-icon"></i>
<input type="text" class="input-field" name="name" placeholder="Name" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-id-card input-icon"></i>
<input type="text" class="input-field" name="student-number" placeholder="Student Number" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-envelope input-icon"></i>
<input type="email" class="input-field" name="email" placeholder="Email" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-lock-alt input-icon"></i>
<input type="password" class="input-field" name="password" placeholder="Password" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-lock-alt input-icon"></i>
<input type="password" class="input-field" name="confirm-password" placeholder="Confirm Password" autocomplete="off" required>
</div>
</div>
<div class="input-submit">
<button class="submit-btn" type="submit">Sign Up</button>
</div>
<div class="sign-in-link">
<p>Already have an account? <a href="/index.html">Sign In</a></p>
</div>
</form>
</div>
Please Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!
everytime i click the signup button it shows that error, even if the action is empty
do you have any other code for this page?
i have, it’s a hole index html, here:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/styles/signupstyle.css">
<link rel="icon" type="png" href="/photos/cvsulogo.png">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<title>CVSU - Carmona - Sign Up</title>
</head>
<body>
<header class="header-bar">
<img src="/photos/cvsulogo.png" alt="CVSU Logo" class="logo">
<h1 class="school-name">Cavite State University - Carmona</h1>
</header>
<div class="bgopacity"></div>
<div class="wrapper">
<form action="" method="post">
<div class="login-header">
<header>Sign Up</header>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-user input-icon"></i>
<select name="user-type" class="input-field">
<option value="" disabled selected>Select your role</option>
<option value="student">Student</option>
<option value="professor">Professor</option>
<option value="faculty">Faculty</option>
</select>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-user input-icon"></i>
<input type="text" class="input-field" name="name" placeholder="Name" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-id-card input-icon"></i>
<input type="text" class="input-field" name="student-number" placeholder="Student Number" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-envelope input-icon"></i>
<input type="email" class="input-field" name="email" placeholder="Email" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-lock-alt input-icon"></i>
<input type="password" class="input-field" name="password" placeholder="Password" autocomplete="off" required>
</div>
</div>
<div class="input-box">
<div class="input-container">
<i class="bx bx-lock-alt input-icon"></i>
<input type="password" class="input-field" name="confirm-password" placeholder="Confirm Password" autocomplete="off" required>
</div>
</div>
<div class="input-submit">
<button class="submit-btn" type="submit">Sign Up</button>
</div>
<div class="sign-in-link">
<p>Already have an account? <a href="/index.html">Sign In</a></p>
</div>
</form>
</div>
<footer class="footer">
<div class="social-media">
<a href="https://facebook.com" target="_blank" class="social-icon">
<i class="bx bxl-facebook"></i>
</a>
<a href="https://twitter.com" target="_blank" class="social-icon">
<i class="bx bxl-twitter"></i>
</a>
<a href="https://instagram.com" target="_blank" class="social-icon">
<i class="bx bxl-instagram"></i>
</a>
<a href="https://linkedin.com" target="_blank" class="social-icon">
<i class="bx bxl-linkedin"></i>
</a>
</div>
<div class="footer-content">
<p>© 2024 Cavite State University - Carmona. All rights reserved.</p>
</div>
</footer>
</body>
</html>
what about JavaScript? do you have any for this page?
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
none, but i am planning to add this action code, a php code to connect it to a local mysql database
<?php
// Configuration
$db_host = 'localhost';
$db_username = 'root';
$db_password = '';
$db_name = 'cvsu_db';
// Create connection
$conn = new mysqli($db_host, $db_username, $db_password, $db_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$user_type = $_POST["user-type"];
$name = $_POST["name"];
$student_number = $_POST["student-number"];
$email = $_POST["email"];
$password = $_POST["password"];
$confirm_password = $_POST["confirm-password"];
// Validate form data
if (empty($user_type) || empty($name) || empty($student_number) || empty($email) || empty($password) || empty($confirm_password)) {
$error = "Please fill in all fields.";
} elseif ($password != $confirm_password) {
$error = "Passwords do not match.";
} else {
// Hash password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Insert data into database
$query = "INSERT INTO users (user_type, name, student_number, email, password) VALUES (?, ?, ?, ?, ?)";
$stmt = $conn->prepare($query);
$stmt->bind_param("sssss", $user_type, $name, $student_number, $email, $hashed_password);
$stmt->execute();
// Check if data was inserted successfully
if ($stmt->affected_rows > 0) {
$success = "Account created successfully!";
} else {
$error = "Error creating account.";
}
}
}
// Close connection
$conn->close();
?>
the default behaviour of the submit button in a form is to do a POST call and reload/redirect to a new page, if you have not set anything to deal with that, it makes sense you get a 405 error ( The HTTP 405 status code indicates that the server has received your request, but the resource you are requesting doesn’t support the request method.)
Add the code to determine the behaviour of the form, and see what happens.
it still has the same error, i’m at my limit i am solving this for 3 hours, please help me : (
is that url set up to receive an API call? or is that just the file that has the code that should run?
this is the content of signup.php
<?php
// Configuration
$db_host = 'localhost';
$db_username = 'root';
$db_password = '';
$db_name = 'cvsu_db';
// Create connection
$conn = new mysqli($db_host, $db_username, $db_password, $db_name);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Process form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$user_type = $_POST["user-type"];
$name = $_POST["name"];
$student_number = $_POST["student-number"];
$email = $_POST["email"];
$password = $_POST["password"];
$confirm_password = $_POST["confirm-password"];
// Validate form data
if (empty($user_type) || empty($name) || empty($student_number) || empty($email) || empty($password) || empty($confirm_password)) {
$error = "Please fill in all fields.";
} elseif ($password != $confirm_password) {
$error = "Passwords do not match.";
} else {
// Hash password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Insert data into database
$query = "INSERT INTO users (user_type, name, student_number, email, password) VALUES (?, ?, ?, ?, ?)";
$stmt = $conn->prepare($query);
$stmt->bind_param("sssss", $user_type, $name, $student_number, $email, $hashed_password);
$stmt->execute();
// Check if data was inserted successfully
if ($stmt->affected_rows > 0) {
$success = "Account created successfully!";
} else {
$error = "Error creating account.";
}
}
}
// Close connection
$conn->close();
?>
so I guess it’s not setup to receive an API call? then do not put that url as action
of the form
You need to suppress the default behaviour and define yourself the behaviour of clicking the button.