daveh / php-signup-login Goto Github PK
View Code? Open in Web Editor NEWSource code to accompany this video: https://youtu.be/5L9UhOnuos0
Home Page: https://youtu.be/5L9UhOnuos0
License: MIT License
Source code to accompany this video: https://youtu.be/5L9UhOnuos0
Home Page: https://youtu.be/5L9UhOnuos0
License: MIT License
Line 15 in f059651
Hello I want to ask how to make same as email but now with name "already taken" I tried but didn't work.
<?php
$mysqli = require __DIR__ . "/database.php";
// Check if $_GET["name"] is set and not empty
$name = isset($_GET["name"]) ? trim($_GET["name"]) : "";
// Check if email is not empty after trimming
if (!empty($name)) {
$escaped_name = $mysqli->real_escape_string($name);
$sql = "SELECT * FROM user WHERE name = '$escaped_name'";
$result = $mysqli->query($sql);
if ($result !== false) {
$is_available = $result->num_rows === 0;
echo json_encode(["available" => $is_available]);
} else {
die("Error: " . $mysqli->error);
}
} else {
echo json_encode(["error" => "Invalid or empty email parameter"]);
}
?>
I tried like this but didn't work
Thank you!
Constantly receiving the error "email already taken" even though the database is empty. connection works, all fields are labeled correctly.... let me know if any further info is needed.
Hello. When i try to register, i am greeted with this message: Field 'id' doesn't have a default value 1364
I dont know what this means but all i know is its preventing the details to go into the database.
Any help would be greatly appreciated.
Thanks in advance!
First i tryed to make the code work on my test website, didnt work. Then I copied the exact code you provided without anything else. once i click submit I only get this displayed :
stmt_init(); if ( ! $stmt->prepare($sql)) { die("SQL error: " . $mysqli->error); } $stmt->bind_param("sss", $_POST["name"], $_POST["email"], $password_hash); if ($stmt->execute()) { header("Location: signup-success.html"); exit; } else { if ($mysqli->errno === 1062) { die("email already taken"); } else { die($mysqli->error . " " . $mysqli->errno); } } ?>
Hello, I was following your tutorial up to the point where the ability to insert a new record is created. However, I've been unable to have the form submit information from the inputs; submitting the form only results in the generic HTTP ERROR 500. The only further details I can find (through the Google Chrome console) is "No resource with given URL found", and "crbug/1173575, non-JS module files deprecated".
Like what the title said, the validation.js isn't working. It's not showing the "red error" text on the sign-up page. Did I do something wrong? Tested it on both edge and chrome.
I am getting an error after submitting the Signup form (Signup.html):
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\database.php on line 17
Database.php contents:
connect_errno) { die("Connection error: " . $mysqli->connect_error); } return $mysqli;on signup page
the password validation is not working - browser debugger throws following error
Uncaught TypeError: Cannot read properties of undefined (reading 'em')
at Object.validator (validation.js:40:54)
at Object.validateFieldRule (just-validate.production.min.js:1:13737)
at just-validate.production.min.js:1:14463
at Array.forEach ()
at Object.validateField (just-validate.production.min.js:1:14437)
at Object.handleFieldChange (just-validate.production.min.js:1:4444)
at HTMLInputElement. (just-validate.production.min.js:1:4713)
Hi Dave I've gotten stuck and I don't know how to overcome this after trying for some time now.
The form is sending data to my user table with the signup being successful the issue is the login form doesn't work due to the password array key not being identified.
Warning: Undefined array key "password" in C:\xampp\htdocs\login-form\login.php on line 17
16 if ($user) {
17 if (password_verify($_POST["password"], $user["password_hash"])) {
18 die("Login Successful");
19 }
20 }
the repository is below.
https://github.com/Tashfinz/signup
Hello,
Everything works fine except for the prevention of duplicate emails. It appears that there is an error in the process-signup.php. The code was copied directly from the source provided. Perhaps, I inadvertently added or omitted a character.
ERROR RECEIVED when a duplicate email was added for a new user:
Fatal error: Uncaught mysqli_sql_exception: Duplicate entry '[email protected]' for key 'email' in C:\xampp\htdocs\php-signup-login-main\process-signup.php:45 Stack trace: #0 C:\xampp\htdocs\php-signup-login-main\process-signup.php(45): mysqli_stmt->execute() #1 {main} thrown in C:\xampp\htdocs\php-signup-login-main\process-signup.php on line 45
This is the code for http://localhost/php-signup-login-main/process-signup.php:
stmt_init(); if ( ! $stmt->prepare($sql)) { die("SQL error: " . $mysqli->error); } $stmt->bind_param("sss", $_POST["name"], $_POST["email"], $password_hash); if ($stmt->execute()) { header("Location: signup-success.html"); exit; } else { if ($mysqli->errno === 1062) { die("email already taken"); } else { die($mysqli->error . " " . $mysqli->errno); } }Hi Daveh,
I was following your login video and I found that not only could I not get the JustValidate to work on my own project, but it came to my attention after downloading this repo it doesn't appear to work as demonstrated in the video 36:20 . Is there perhaps any refactoring that needs be done to get this to work as intended for frontend validation?
https://www.youtube.com/watch?v=5L9UhOnuos0&list=WL&index=7&t=2142s&ab_channel=DaveHollingworth
line 7: $mysqli->real_escape_string($_GET["email"]));
Fatal error: Uncaught mysqli_sql_exception: Duplicate entry '[email protected]' for key 'email' in C:\xampp\htdocs\php-signup-login\process-signup.php:45 Stack trace: #0 C:\xampp\htdocs\php-signup-login\process-signup.php(45): mysqli_stmt->execute() #1 {main} thrown in C:\xampp\htdocs\php-signup-login\process-signup.php on line 45
I keep getting this error and don't know what to do .
Line 15 in f059651
signup-process.php : an error occurred in mentioned file,
why these lines of codes doesn't work
}else {
if ($mysqli->errno === 1062) {
die("email already taken");
} else {
die($mysqli->error." ".$mysqli->errno);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.