나는 이것을 잘못 작성했다고 확신합니다. 나는 정보를 프로세스 페이지로 보내고 데이터베이스의 테이블에 행을 삽입하는 비트를 입력하는 간단한 양식을 가지고 있습니다. 내 문제는 삽입 부분이 잘 작동한다는 것입니다. 그러나 페이지 내의 템플릿 클래스 또는 다른 것이 표시됩니다. 그냥 빈 페이지. 그 말은 날 미치게했다.PHP 폼 업데이트 모범 사례
함수
Public function UpdateReason($reason, $bundlereference) {
error_reporting(E_ALL^E_NOTICE);
$db_selected = mysql_select_db(DB_DATABASE_NAME, $this->conn);
if (!$db_selected) {
die("Can't use db : " . mysql_error());
}
$_reason = mysql_real_escape_string($reason,$this->conn);
$_bundlereference = mysql_real_escape_string($bundlereference,$this->conn);
$sql = "UPDATE `ArchiveBundle`
SET `Issue` = '" . $_reason . "'
WHERE `BundleReference` = '" . $_bundlereference . "'";
mysql_query($sql, $this->conn);
die(mysql_error());
exit;
}
형태
<table>
<form method='post' action='addissue.php'>
<p>Reason: <input type='text' name='reason' /></p><br/>
<p><input type='hidden' name='bundlereference' id='Username'
value='" . $x['Reference'] . "' /></p>
<input type='submit' name ='add'/>
</form>
</table>
프로세스 페이지도
<?php
// First of all initialise the user and check for permissions
require_once "/var/www/users/user.php";
$user = new CHUser(2);
// Initialise the template
require_once "/var/www/template/template.php";
$template = new CHTemplate();
// And create a cid object
require_once "/var/www/Testing/DisplayWIPOnLocation.php";
$BundleProgress= new CHWIPProgress();
$reason = $_POST['reason'];
$reference = $_POST['bundlereference'];
$issue = $BundleProgress->UpdateReason($_POST['reason'],$_POST['bundlereference']);
Print "Your information has been successfully added to the database.";
$template->SetTag("content", $content);
echo $template->Display();
?>
I이 궁금한 점이 있으시면 php의 양식에 대한 베스트 프랙티스가 무엇인지 배울 수 있습니다.
'die (mysql_error()); exit;이 명령어는 PHP 실행을 완전히 멈추게 만들고, 적어도 첫 번째는 exit이고, exit는 어쨌든 die의 별칭입니다. – SirDarius