이것은 제가 작업하고 있는 테스트 페이지입니다. 다음 페이지 "order.php"를 로드하기 위해 제출 버튼을 얻으려고 합니다.
계속해서 같은 페이지만 로드됩니다. 이 글을 PHP로 작성해야 할까요, 아니면 HTML로 작성해야 할까요?
내 제출 버튼을 보면 이것이 작동할 것이라고 생각합니다.
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
require_once('connect2db.php');
if(isset($_POST["action"])){
$customer = $_POST['customer'];
$Email = $_POST['Email'];
$query = "INSERT INTO tbl_cust
(CName, email)
VALUES
(:customer, :Email)";
$sth = $db->prepare($query);
$sth->bindValue(':customer', $customer, PDO::PARAM_STR);
$sth->bindValue(':Email', $Email, PDO::PARAM_STR);
$sth->execute();
echo 'Form Submitted and data saved!';
}
?>
<!DOCTYPE html>
<html class="html" lang="en-US">
<head>
<meta http-equiv="Content-type" content="text/html; <title>Home</title>
</head>
<body>
<div class="clearfix" id="page">
<form class="form-grp clearfix colelem" id="widgetu75" method="post" enctype="multipart/form-data" action="">
<input type="hidden" name="action" value="submit-form">
<label>Name:</label>
<input class="wrapped-input" type="text" spellcheck="false" id="widgetu86_input" name="customer" tabindex="1"/>
<label>Email:</label>
<input class="wrapped-input" type="text" spellcheck="false" id="widgetu82_input" name="Email" tabindex="2"/>
<input class="submit-btn NoWrap grpelem" id="u81-17" type="submit" value="Submit" href="order.php" target="_blank"" ttabindex="3"/>
</form>
</div>
</body>
</html>
답변1
작업을 ""에서 "order.php"로 변경해 보세요.