Невозможно передать вводимое пользователем значение на следующей странице в веб-форме с использованием php - PullRequest
0 голосов
/ 09 июля 2020

Вот коды, которые я пробовал последними. С этими кодами я ничего не получил в поле ввода. Я хочу, чтобы пользователь мог видеть, что он ввел, но не мог изменить то же самое. если он хочет изменить, он должен go вернуться на предыдущую страницу и заполнить данные правильным значением.

Для страницы 1 (с расширением php)

<?PHP
session_start();
?>

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type = "text/css" href="index.css"/>
  <title>EduLife Welcomes You</title>
  <link rel="icon" type="image/png" href="title-icon.png"/>
</head>

<body>

<?php
// Set session variables

$_SESSION['dob'] = $dob;
$_SESSION['class'] = $class;

?>
[...javascript for calculating age...]
  <form>
  <h3>Check Eligibility : </h3>
  Enter Date of Birth of the child: <input type="date" name="dob" id="dob" required/><br>
  <input class="btn" type="button" value="Check Eligibility" onclick="ageCalculate()"><br>
  You are eligible for the Grade : <span id="class" class="eligible"></span>
  </form>

<a href="/PAGE2.php" ><button id="ready">OK, I want to apply!</button></a>
</body>
</html>

КОД ДЛЯ СТРАНИЦЫ 2 (с расширением php)

<?PHP
session_start();

$dob = $_SESSION['dob'];
$class = $_SESSION['class'];
?>

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type = "text/css" href="admn-form.css"/>
  <title>EduLife</title>
  <link rel="icon" type="image/png" href="title-icon.png"/>
</head>
<div id="admn-form"> 
<form action="insert.php" method="POST">
<h2  id="form-name">Apply For Admission </h2>
<h2 id="part"> Part A - Information of the student</h2>

<h3><span style="color:blue">You applying for the Grade:</span><input for="class" name="class" id="class" value="<?php echo $_SESSION['class'];?>" readonly> </input></h3>

<h3>1. Name of the student</h3>
<p class="quest">
        <label for="first-name"> First Name * : </label>
        <input type="text" Name="firstname" placeholder="First Name" pattern="[A-Z]{2,15}" required>
        <label for="middle-name"> Middle Name : </label>
        <input type="text" Name="middlename" placeholder="Middle Name" pattern="[^\s][A-Z]+{2,15}">
        <label for="last-name"> Last Name : </label>
        <input type="text" Name="lastname" placeholder="Last Name" pattern="[^\s][A-Z]+{2,15}">
</p>
<h3>2. Select Gender of the student *</h3>
<p class="quest">
        <input type="radio" id="female" name="gender" value="Female" required>
        <label for="female">Female</label>
        <input type="radio" id="male" name="gender" value="Male" required>
        <label for="male">Male</label>
        <input type="radio" id="other" name="gender" value="Other" required>
        <label for="other">Other</label>
</p>

<h3>4. Enter Birth-detail of the student</h3>
<p class="quest">
        <label for="DOB"> Date of Birth *: </label> 
        <input type="date" name="dob" value="<?php echo $_SESSION['dob'];?>" readonly>
</p>
</form>
</div>
</HTML>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...