表单无效,请转到action-page.php

时间:2015-06-16 10:54:28

标签: forms

我对PHP有点新,我不能让我的表单工作。当我点击“提交”直接进入空白页面,但在URL栏中显示:../ action-page.php

我真的希望有人可以帮我解决这个问题......我会非常感谢!

这是我的HTML代码:(抱歉长度)

<form method="post" action="action-page.php">
<TABLE cellpadding=0 cellspacing=0 class="t0" style="vertical-align:middle;">
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Country:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="country" /></TD>
</TR>
<TR>    
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Assigned product(s):</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="assigned_products" /></TD></TR>
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Association:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="association" /></TD></TR>
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Competitor (Mr/Miss/Mrs):</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="competitor" /></TD></TR>
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Place of employment:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="place_of_employment" /></TD></TR>
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Competitor’s Email:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="competitors_email" /></TD></TR>
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Date of birth:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="date_of_birth" /></TD></TR>
<TR>
<TD style="width:220px; padding-bottom:10px;"><P class="p5 ft2">Name of Cocktail:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="70" maxlength="200" name="name_of_cocktail" /></TD></TR></TABLE>
<TABLE cellpadding=0 cellspacing=0 class="t0">
<TR>
<TD style="width:30px;" class="tr6 td33"><P class="p6 ft6">No</P></TD>
<TD style="width:60px;" class="tr6 td34"><P class="p7 ft6">CL.</P></TD>
<TD style="width:290px;" class="tr6 td36"><P class="p8 ft6">Recipe</P></TD>
<TD style="width:301px;" class="tr6 td37"><P class="p7 ft6">Brand Name</P></TD></TR>
<TR>
<TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">1</P></TD>
<TD style="width:60px;" class="tr7 td38">&nbsp;<input type="text" size="3" maxlength="3" name="No 1 - CL" style="border:none;" /></TD>
<TD style="width:290px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 1 - Recipe" style="border:none;" /></TD>
<TD style="width:301px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 1 - Brand name" style="border:none;" /></TD></TR>
<TR>
<TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">2</P></TD>
<TD style="width:60px;" class="tr7 td38">&nbsp;<input type="text" size="3" maxlength="3" name="No 2 - CL" style="border:none;" /></TD>
<TD style="width:290px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 2 - Recipe" style="border:none;" /></TD>
<TD style="width:301px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 2 - Brand name" style="border:none;" /></TD></TR>
<TR>
<TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">3</P></TD>
<TD style="width:60px;" class="tr7 td38">&nbsp;<input type="text" size="3" maxlength="3" name="No 3 - CL" style="border:none;" /></TD>
<TD style="width:290px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 3 - Recipe" style="border:none;" /></TD>
<TD style="width:301px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 3 - Brand name" style="border:none;" /></TD></TR>
<TR>
<TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">4</P></TD>
<TD style="width:60px;" class="tr7 td38">&nbsp;<input type="text" size="3" maxlength="3" name="No 4 - CL" style="border:none;" /></TD>
<TD style="width:290px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 4 - Recipe" style="border:none;" /></TD>
<TD style="width:301px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 4 - Brand name" style="border:none;" /></TD></TR>
<TR>
<TD style="width:30px;" class="tr7 td38A"><P class="p6 ft7">5</P></TD>
<TD style="width:60px;" class="tr7 td38">&nbsp;<input type="text" size="3" maxlength="3" name="No 5 - CL" style="border:none;" /></TD>
<TD style="width:290px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 5 - Recipe" style="border:none;" /></TD>
<TD style="width:301px;" class="tr7 td38">&nbsp;<input type="text" size="38" maxlength="200" name="No 5 - Brand name" style="border:none;" /></TD></TR>
<TR>
<TD style="width:30px;" class="tr7 td38B"><P class="p6 ft7">6</P></TD>
<TD style="width:60px;" class="tr7 td38C">&nbsp;<input type="text" size="3" maxlength="3" name="No 6 - CL" style="border:none;" /></TD>
<TD style="width:290px;" class="tr7 td38C">&nbsp;<input type="text" size="38" maxlength="200" name="No 6 - Recipe" style="border:none;" /></TD>
<TD style="width:301px;" class="tr7 td38C">&nbsp;<input type="text" size="38" maxlength="200" name="No 6 - Brand name" style="border:none;" /></TD></TR></TABLE>
<P class="p9 ft10">Please write legibly in block letters. Maximum 6 ingredients and not more than 7cl of alcohol as base.</P>
<TABLE cellpadding=0 cellspacing=0 class="t0" style="vertical-align:middle;">
<TR>
<TD style="width:350px; padding-bottom:10px;"><p class="p5 ft2">Garnish:</p></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Garnish" /></TD></TR>
<TR>    
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Decoration:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Decoration" /></TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">&nbsp;</P></TD>
<TD style="width:350px; padding-bottom:10px;"><input type="radio" name="Build-Stir-Shake-Blend" value="Build" />Build <input type="radio" name="Build-Stir-Shake-Blend" value="Stir" />Stir <input type="radio" name="Build-Stir-Shake-Blend" value="Shake" />Shake <input type="radio" name="Build-Stir-Shake-Blend" value="Blend" />Blend </TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Glass:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Glass" /></TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Contact person:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Contact person" /></TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Title:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Title" /></TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Checked and approved by Guild President:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Checked and approved by Guild President" /></TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Email:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Email" /></TD></TR>
<TR>
<TD style="width:350px; padding-bottom:10px;"><P class="p5 ft2">Fax/Tel:</P></TD>
<TD style="padding-bottom:10px;"><input type="text" size="50" maxlength="200" name="Fax/Tel" /></TD></TR></TABLE>
<TABLE cellpadding=0 cellspacing=0 class="t3" style="vertical-align:middle;">
<TR>
<TD style="width:681px; padding-bottom:10px;"><p style="font-size:15px; font:'Times New Roman'; font-style:normal;">WCC entry forms must be accompanied by a picture of the competitor, as a <strong>separate file:</strong></br></br>
<input type="file" name="userfile" />
</br></br>
<strong>- Close-up</strong> (portrait, no “action shot“)</br>
<strong>- Full-color</br>
- High resolution</strong> (at least 1Mb, but preferably higher)</p></TD></TR></TABLE>

这是我的action-page.php :(我还没有从表单中输入所有的fiels,希望不是问题?我想先检查一下是否有效)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Before Dinner Cocktail Competition</title></head>

<body>

<?php
$naar = 'info@sightdraft.nl'; // Waar moet het naartoe?
$onderwerp = 'Registration form Before Dinner Cocktail Competition'; // Het onderwerp van het bericht

// Header instellen, zodat nl2br() werkt
$headers = "MIME-version: 1.0\r\n";
$headers .= "content-type: text/html;charset=utf-8\r\n";

if(isset($_POST['send'])) // Als het formulier verzonden is door op de verzend knop te klikken
{
$country = trim($_POST['country']); // Alle overbodige spaties uit het country veld verwijderen
$assigned_products = trim($_POST['assigned_products']); // Alle overbodige spaties uit het assigned_products veld verwijderen
$association = trim($_POST['association']); // Alle overbodige spaties uit het association veld verwijderen
$competitor = trim($_POST['competitor']); // Alle overbodige spaties uit het competitor veld verwijderen
$place_of_employment = trim($_POST['place_of_employment']); // Alle overbodige spaties uit het place_of_employment veld verwijderen
$competitors_email = trim($_POST['competitors_email']); // Alle overbodige spaties uit het competitors_email veld verwijderen
$date_of_birth = trim($_POST['date_of_birth']); // Alle overbodige spaties uit het date_of_birth veld verwijderen
$name_of_cocktail = trim($_POST['name_of_cocktail']); // Alle overbodige spaties uit het name_of_cocktail veld verwijderen

$fout = false; // Om te kijken straks of er wat fout is

if(empty($country)) // Als het country veld niet is ingevuld
{
print '<p>Sorry, the "country" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($assigned_products)) // Als het assigned_products veld niet is ingevuld
{
print '<p>Sorry, the "assigned products" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($association)) // Als het association veld niet is ingevuld
{
print '<p>Sorry, the "association" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($competitor)) // Als het competitor veld niet is ingevuld
{
print '<p>Sorry, the "competitor" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($place_of_employment)) // Als het place_of_employment veld niet is ingevuld
{
print '<p>Sorry, the "place of employment" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($date_of_birth)) // Als het date_of_birth veld niet is ingevuld
{
print '<p>Sorry, the "date of birth" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($name_of_cocktail)) // Als het name_of_cocktail veld niet is ingevuld
{
print '<p>Sorry, the "name of cocktail" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}
if(empty($competitors_email)) // Als het competitors_email veld niet is ingevuld
{
print '<p>Sorry, the "competitors email" field is compulsory!</p>';
$fout = true; // Zorgen dat het script zometeen weet dat er wat fout is
}


if(!filter_var($competitors_email, FILTER_VALIDATE_EMAIL)) // Als het email adres niet correct is
{
print '<p>Sorry, the emailadress is not correct!</p>';
$fout = true;
}
if(empty($bericht)) // Als het bericht veld niet is ingevuld
{
print '<p>Sorry, this is a compulsory field and needs to be filled!</p>';
$fout = true;
}

if($fout == false) // Als er niks fout is (alles is dus netjes ingevuld)
{
$headers .= 'From: ' . $competitor . '<' . $competitors_email . '>'; // Een afzender instellen zodat je kan reageren.

if(mail($naar, $onderwerp, nl2br($name_of_cocktail), $headers))
{
print '<p>The registration was send succesfully!</p>';
}
else
{
print '<p>Sorry, something went wrong while sending the form.</p>';
}
}
}
?>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

在您的action-page.php文件中,您正在检查是否已发布发送。但是在您的表单中,您没有名为“send”的提交输入。

你甚至没有结束表格标签?