HTML, PHP 및 부트 스트랩 트위터를 사용하여 웹 사이트 (http://youngliferaffle.com/)에 양식을 만들려고합니다. 나는 그것을 만드는 방법에 대한 여러 가지 자습서를 조사했지만, 사용자가 오류를 만들거나 답변을 제출 한 후에 사용자를 이전 할 때처럼 위치에 문제가 있다고 생각합니다. 나는 또한 PHP에 매우 익숙하다. 나는 정말 도움을 주셔서 감사합니다! 고맙습니다!HTML 및 PHP를 사용하여 양식 만들기
주요 문제 :
- "웹 페이지에 리디렉션이 너무 많습니다"올바른 페이지로 리디렉션되지
- 사용자 제출 또는 인한 후 제출로부터 이메일을 수신하지 쿠키
- 에/가능성 때문에 : 나쁜 제출 여기에
내 HTML 양식의 일부입니다
여기서 다시 같은 위치로 향하고 유지, 내 PHP 양식 맨 처음 줄에
// check for form submission - if it doesn't exist then send back to contact form
if (!isset($_POST['save']) || $_POST['save'] != 'contact') {
header('Location: contact-form-submission.php');
exit;
}
// get the posted data
$name = $_POST['contact_name'];
$email_address = $_POST['contact_email'];
$phone = $_POST['contact_phone'];
// check that a name was entered
if (empty($name))
$error = 'You must enter your name.';
// check that an email address was entered
elseif (empty($email_address))
$error = 'You must enter your email address.';
// check for a valid email address
elseif (!preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $email_address))
$error = 'You must enter a valid email address.';
// check that a phone number was entered
elseif (empty($phone))
$error = 'You must enter a phone number.';
// check if an error was found - if there was, send the user back to the form
if (isset($error)) {
//Am I putting the wrong location?
header('Location: contact-form-submission.php?e='.urlencode($error)); exit;
}
// write the email content
$email_content = "Name: $name\n";
$email_content .= "Email Address: $email_address\n";
$email_content .= "Phone:\n\n$phone";
// send the email
mail ("myemail.com", "New Contact Message", $email_content);
// send the user back to the form
//And This is where I'm having trouble with! the Location part
header('Location: contact-form-submission.phps='.urlencode('Thank you for your message.'));
exit;
그래서 어떤 특정 문제가 있습니까? –
이 스크립트는 언제 실행됩니까? contact-form-submission.php, POST contact-form-submission.php 또는 다른 URL을 찾았습니까? – Mateusz
정확하게 입력하지 않아도 양식을 제출하려고 시도하면 양식이 리디렉션되고 웹 페이지 (http://youngliferaffle.com/contact-form-submission.php)에 너무 많은 리디렉션이 있다고합니다. 또한, 정확하게 입력 했더라도 똑같다고 말하면서 이메일을받지 못합니다. – user2363671