Currently, I am using PHP to create an input screen and an input check screen.
As a flow
(1) On the input screen, enter three items: "Name", "Password to register", and "Password same as registered password".
(2) On the input check screen, "Name" will be displayed if it is correctly entered on the input screen, and if it is not entered correctly, "Name is not entered" or "Password is entered" will be displayed according to the mistake. "No password" or "Password does not match."
It becomes the flow that.
, "Name is not entered" is displayed on the input check screen even though the name was entered on the input screen. Specific situations and images are listed below. I would appreciate your help.
Error messageEven if a name is entered on the input screen, the message "No name entered" appears on the input check screen.
For example, if you enter the following on the input screen
On the input check screen, the result is that the staff name is not entered even though the name should have been entered
However, if everything is entered correctly on the input screen,
The name is reflected on the input check screen.
The code for the input screen.
staff_add.php
<! DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<title>Rokumaru farm</title>
</head>
<body>
Add staff<br />
<br />
<form method = "post" action = "staff_add_check.php">
Please enter a staff name.<br />
<input type = "text" name = "name" style = "width: 200px"><br />Please enter your password<br />
<input type = "password" name = "pass" style = "width: 100px"><br />
Please enter your password again.<br />
<input type = "password" name = "pass2" style = "width: 100px"><br />
<br />
<input type = "button" onclick = "history.back ()" value = "Back">
<input type = "submit" value = "OK">
</form>
</body>
</html>
Input check screen code
staff_add_check.php
<! DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<title>Rokumaru farm</title>
</head>
<body>
<? php
$staff_name = $_POST ['name'];
$staff_pass = $_POST ['pass'];
$staff_pass2 = $_POST ['pass2'];
$staff_name = htmlspecialchars ($staff_name, ENT_QUOTES, 'UTF-8');
$staff_name = htmlspecialchars ($staff_pass, ENT_QUOTES, 'UTF-8');
$staff_pass2 = htmlspecialchars ($staff_pass2, ENT_QUOTES, 'UTF-8');
if ($staff_name == '') {
print'staff name is not entered.<br />';
}
else {
print 'Staff Name:';print $staff_name;
print '<br />';
}
if ($staff_pass == '') {
print 'Password has not been entered.<br />';
}
if ($staff_pass! = $staff_pass2) {
print 'Password does not match.<br />';
}
if ($staff_name == '' || $staff_pass == '' || $staff_pass! = $staff_pass2) {
print '<form>';
print '<input type = "button" onclick = "history.back ()" value = "back">';
print '</form>';
}
else {
$staff_pass = md5 ($staff_pass);
print '<form method = "post" action = "staff_add_done.php">';
print '<input type = "hidden" name = "name" value = "'. $staff_name. '">';
print '<input type = "hidden" name = "pass" value = "'. $staff_pass. '">';
print '<br />';
print '<input type = "button" onclick = "history.back ()" value = "back">';
print '<input type = "submit" value = "OK">';
print '</form>';
}
?>
</body>
</html>
I thought it might not have been sent to $_POST because of garbled characters, so I created .htaccess in the directory, but the result did not change.
I checked whether the name in the input tag of the HTML code was different, but it was the same.
The OS is macOS Catalina 10.15.1.
-
Answer # 1
Related articles
- php - i want to solve tle of array problem
- i want to solve a php function problem! !!
- php - i want to solve the problem that an error occurs as soon as i put $result = $stmt-> fetch (pdo :: fetch_assoc) ;
- i want to solve the reason why the entered information is not displayed in the email sent from the inquiry form created with php
- php - how to select and display the information (store name/address etc) registered in advance on the wordpress post page
- php - i want to retrieve database information, but i can't
- i can't solve the javascript problem
- csv - i would like to know how to solve the problem that the data related to the time output by scraping python3 is output to an
- i want to check the form input with php, display an error on the same page if it is not filled in, and move to another page only
- php - i want to call my name using my membership information, but
- github - i want to solve the problem that git push heroku master is played
- exif information of images taken with iphone camera cannot be obtained correctly from php
- problem that standard input is not possible when executing vue create command with docker-compose up
- php: tell us about the application of the fizzbuzz problem!
- php - i want to change the memory_limit setting to solve the memory shortage
- i want to solve the ssl error "dh key too small in" that appears when using the national diet library api with php
- php - [laravel] i want to display the information of the related table in my page
- php - i want to display the website of the url entered in input in the html form in real time using iframe
- unable to save input home contents in database with php
- edit user information of each logged-in user without using db in php
- php - i want to reflect the datetime data saved in mysql in the value of and display it initially
- i want to resolve a php error syntax error, unexpected end of file
- php - i want to display an alert when the page is closed
- php - about the local development environment for web application development
- php - access mysql on the x server locally
- php - how can i prohibit the download (terminal storage) of images on my homepage?
- php - the site is suddenly judged as mixed content
- php - even though the page is being displayed on https, $_server ['https'] is judged as null
- php - if the value is empty, i want to display all terms as search results
- php - check box is it possible to determine whether or not there is a check and branch?
It is overwritten with another value immediately after.
That's true if $staff_pass is empty.
Snacks:
There is no use for htmlspecialchars ().
At this timing, the input check is performed with the converted value at the time of input check.
Please insert when displaying.
Sanitize/Input value verification/Escape concept
Please say "Why do you pass htmlspecialchars?"