PHP 파일에 양식 데이터를 게시하는 HTML 파일이 있습니다 (또는 어쨌든 가정되어 있습니다). HTML과 PHP 파일은 프로젝트의 같은 폴더에 있지만 양식을 제출하면 "리소스를 찾을 수 없습니다."라는 PHP 파일의 이름은 "patient_json.php"입니다.PHP 파일을 찾을 수 없습니다
그들은 PHP 파일이 될 수없는 이유를 내가 알아낼 수 없습니다 프로젝트의 같은 폴더에, 다시<?php
// check if all form data are submited, else output error message
if(isset($_POST['fname']) && isset($_POST['lname']) && isset($_POST['bday']) && isset($_POST['location']) && isset($_POST['pat_ssn'])) {
// if form fields are empty, outputs message, else, gets their data
if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['bday']) || empty($_POST['location']) || empty($_POST['pat_ssn'])) {
echo 'All fields are required';
}
else {
// adds form data into an array
$formdata = array(
'firstname'=> $_POST['fname'],
'lastname'=> $_POST['lname'],
'bday'=> $_POST['bday'],
'location'=> $_POST['location'],
'ssn'=> $_POST['pat_ssn']
);
// encodes the array into a string in JSON format (JSON_PRETTY_PRINT - uses whitespace in json-string, for human readable)
$jsondata = json_encode($formdata, JSON_PRETTY_PRINT);
// saves the json string in "pat_data.txt"
// outputs error message if data cannot be saved
if(file_put_contents('pat_data.txt', $jsondata)) echo 'Data successfully saved';
else echo 'Unable to save data in "formdata.txt"';
}
}
else echo 'Form fields not submitted';
// path and name of the file
$filetxt = 'pat_data.txt';
// check if the file exists
if(file_exists($filetxt)) {
// gets json-data from file
$jsondata = file_get_contents($filetxt);
// converts json string into array
$arr_data = json_decode($jsondata, true);
// Now you can use the array $arr_data with json-data saved in text file
var_export($arr_data); // Test to see the array
}
else echo 'The file '. $filetxt .' not exists';
// path and name of the file
$filetxt = 'pat_data.txt';
// check if all form data are submited, else output error message
if(isset($_POST['fname']) && isset($_POST['lname']) && isset($_POST['bday']) && isset($_POST['location']) && isset($_POST['pat_ssn'])) {
// if form fields are empty, outputs message, else, gets their data
if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['bday']) || empty($_POST['location']) || empty($_POST['pat_ssn'])) {
echo 'All fields are required';
}
else {
// gets and adds form data into an array
$formdata = array(
'firstname'=> $_POST['fname'],
'lastname'=> $_POST['lname'],
'bday'=> $_POST['bday'],
'location'=> $_POST['location'],
'ssn'=> $_POST['pat_ssn']
);
// path and name of the file
$filetxt = 'pat_data.txt';
$arr_data = array(); // to store all form data
// check if the file exists
if(file_exists($filetxt)) {
// gets json-data from file
$jsondata = file_get_contents($filetxt);
// converts json string into array
$arr_data = json_decode($jsondata, true);
}
// appends the array with new form data
$arr_data[] = $formdata;
// encodes the array into a string in JSON format (JSON_PRETTY_PRINT - uses whitespace in json-string, for human readable)
$jsondata = json_encode($arr_data, JSON_PRETTY_PRINT);
// saves the json string in "pat_data.txt"
// outputs error message if data cannot be saved
if(file_put_contents('pat_data.txt', $jsondata)) echo 'Data successfully saved';
else echo 'Unable to save data in "pat_data.txt"';
}
}
else echo 'Form fields not submited';
?>
:
여기 여기
@using OnboardingProject.App_Code
@using OnboardingProject.Controllers
@{
ViewBag.Title = "Patients";
}
<div class="title">
<div>
<h1 style="float: left">@ViewBag.Title</h1>
</div>
<div class="rmm" style="float: right; display: inline-block">
<ul>
<li><button id="NewPatient">New Patient</button></li>
</ul>
</div>
</div>
<div id="modal_content">
<div id="modal_window" title="Complete the form below to add a new patient:">
<div style="text-align: right;"><a id="modal_close" href="#">close <b>X</b></a></div>
<form id="add_patient" method="POST" action="patient_json.php" accept-charset="UTF-8">
<p><label>First Name<strong>*</strong><br>
<input type="text" autofocus required size="48" id="fname" value=""></label></p>
<p><label>Last Name<strong>*</strong><br>
<input type="text" autofocus required size="48" id="lname" value=""></label></p>
<p><label>Birthdate (mm/dd/yyyy)<strong>*</strong><br>
<input type="text" autofocus required size="48" id="bday" value=""></label></p>
<p><label>Site Name<strong>*</strong><br>
<input type="text" autofocus required size="48" id="location" value=""></label></p>
<p><label>SSN<strong>*</strong><br>
<input type="text" autofocus required size="48" id="pat_ssn" value=""></label></p>
<p><input type="submit" id="addPatient" value="Add Patient"></p>
</form>
</div>
</div>
<div class="content">
<div id="patient_table">
<table id="patients">
<tr>
<th id="p_name">Patient Name</th>
<th id="p_site">Site</th>
<th id="dob">Date of Birth</th>
<th id="ssn">SSN</th>
<th id="edits"></th>
</tr>
</table>
</div>
</div>
<script src="@Url.Content("~/Scripts/PatientInfo.js")" type="text/javascript"></script>
내 PHP 파일 내 HTML입니다 발견 된 아이디어?
된다. – andrew
죄송합니다 그것은 유형 -o입니다. PHP 파일 이름은 patient_json.php입니다. 모두들 미안해! – AtlasBowler