PHP引导程序形式重定向错误

时间:2017-10-05 08:00:46

标签: php html forms redirect

我需要你的帮助。我的网站正在使用Bootstrap框架。对于查询产品,我准备了一些html表格。它们的结构如下:

        <form action="../../../scripts/processor.php" method="post" enctype="multipart/form-data" class="form-horizontal" id="form" style="padding-top: 2rem;" accept-charset="UTF-8">
  <div class="form-group">
    <label for="produkt" class="col-sm-3 control-label">Produkt</label>
    <div class="col-sm-9">
      <select class="form-control" name="product" id="product" onChange="checkSelection()">
        <option value="none">Wählen Sie</option>
        <option value="CREAPUR">CREATON Estrichziegel CREAPUR</option>
        <option value="KERATOP">CREATON Estrichziegel KERATOP</option>
      </select>
      <script type="text/javascript">
		  
		  function checkSelection() {
		  if (document.getElementById("product").value === "CREAPUR" ){
			  document.getElementById("farbe-naturrot").disabled=false;
			  document.getElementById("c-naturrot").style.display="inline";
			  document.getElementById("c-anthrazitgrau").style.display="none";
			  document.getElementById("c-altweiß").style.display="none";
			  document.getElementById("c-gelbrot").style.display="none";
		  } else if(document.getElementById("product").value === "KERATOP" ) {
			  document.getElementById("farbe-naturrot").disabled=true;
			  document.getElementById("c-naturrot").style.display="none";
			  document.getElementById("farbe-anthrazitgrau").disabled=false;
			  document.getElementById("c-anthrazitgrau").style.display="inline";
			  document.getElementById("farbe-altweiß").disabled=false;
			  document.getElementById("c-altweiß").style.display="inline";
			  document.getElementById("farbe-gelbrot").disabled=false;
			  document.getElementById("c-gelbrot").style.display="inline";
		  } else{
			  window.alert("Wählen Sie eine Farbe für eine Anfrage");
		  }
		}
		  
		  
		  

		</script> 
    </div>
  </div>
  <div class="form-group">
    <label class="col-sm-3 control-label">Farbe:</label>
    <div class="col-sm-9">
      <label class="radio-inline" id="c-naturrot">
        <input type="radio" name="colour" id="farbe-naturrot" value="naturrot" disabled>
        naturrot </label>
      <label class="radio-inline" id="c-anthrazitgrau">
        <input type="radio" name="colour" id="farbe-anthrazitgrau" value="anthrazitgrau" disabled>
        anthrazitgrau </label>
      <label class="radio-inline" id="c-altweiß">
        <input type="radio" name="colour" id="farbe-altweiß" value="altweiß" disabled>
        altweiß </label>
      <label class="radio-inline" id="c-gelbrot">
        <input type="radio" name="colour" id="farbe-gelbrot" value="gelbrot" disabled>
        gelbrot </label>
    </div>
  </div>
  
  <hr>
  <div class="form-group">
    <label for="contact-type" class="col-sm-3 control-label">Kundenart</label>
    <div class="col-sm-9">
      <label class="radio-inline">
        <input type="radio" name="contacttype" value="private" checked="checked" onClick="hideBusinessDetails()" >
        Privatkunde</label>
      <label class="radio-inline">
        <input type="radio" name="contacttype" value="business" onClick="showBusinessDetails()">
        Geschäftskunde</label>
    </div>
  </div>
  <script type="text/javascript">
	  function showBusinessDetails(){
		  
 document.getElementById("companyinformation").style.display="inline";
	  }
	  
	  function hideBusinessDetails() {
		      document.getElementById("companyinformation").style.display="none";
	  }
	</script>
  <hr>
  <div id="companyinformation" style="display: none">
    <div class="form-group">
      <label for="Firma" class="col-sm-3 control-label">Firma</label>
      <div class="col-sm-9">
        <input name="company" type="text" class="form-control" placeholder="Firmenname" autocomplete="organization">
      </div>
    </div>
    <div class="form-group">
      <label for="Tax-ID" class="col-sm-3 control-label">UST-IdNr.</label>
      <div class="col-sm-9">
        <input name="tax_id" type="text" class="form-control" placeholder="UST-IdNr.">
      </div>
    </div>
    <hr>
  </div>
  <div class="form-group">
    <label for="gender" class="col-sm-3 control-label">Anrede</label>
    <div class="col-sm-9">
      <label class="radio-inline">
        <input type="radio" name="gender" value="female">
        Frau</label>
      <label class="radio-inline">
        <input type="radio" name="gender" value="male">
        Herr</label>
    </div>
  </div>
  <div class="form-group">
    <label for="given_name" class="col-sm-3 control-label">Vorname*</label>
    <div class="col-sm-9">
      <input name="given_name" type="text" required class="form-control" placeholder="Vorname" autocomplete="given-name" data-error="Der Wert für Vorname wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
  </div>
  <div class="form-group">
    <label for="family_name" class="col-sm-3 control-label">Nachname*</label>
    <div class="col-sm-9">
      <input name="family_name" type="text" required class="form-control"  placeholder="Nachname" autocomplete="family-name" data-error="Der Wert für Nachname wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
  </div>
  <div class="form-group">
    <label for="Adresse" class="col-sm-3 control-label">Adresse*</label>
    <div class="col-sm-9">
      <input name="adress" required type="text" class="form-control"  placeholder="Adresse" autocomplete="street-address" data-error="Der Wert für Adresse wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
  </div>
  <div class="form-group">
    <label for="PLZ" class="col-sm-3 control-label">PLZ/Ort*</label>
    <div class="col-sm-2">
      <input name="zip" type="text" required class="form-control" placeholder="Postleitzahl" autocomplete="postal-code" data-error="Der Wert für PLZ wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
    <div class="col-sm-7">
      <label for="Ort" style="display: none">Ort</label>
      <input name="city" type="text" class="form-control" required placeholder="Ort" autocomplete="address-level2" data-error="Der Wert für Ort wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
  </div>
  <div class="form-group">
    <label for="Land" class="col-sm-3 control-label">Land</label>
    <div class="col-sm-9">
      <select class="form-control" name="land">
        <option value="AF">Afghanistan</option>
        ...
      </select>
    </div>
  </div>
  <hr>
  <div class="form-group">
    <label for="E-Mail" class="col-sm-3 control-label">E-Mail*    </label>
    <div class="col-sm-9">
      <input name="email" type="email" required class="form-control"  placeholder="E-Mail" autocomplete="email" data-error="Der Wert für E-Mail wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
  </div>
  <div class="form-group">
    <label for="Telefonnummer" class="col-sm-3 control-label">Telefonnummer</label>
    <div class="col-sm-9">
      <input name="telephone" type="tel" class="form-control"  placeholder="Telefonnummer" autocomplete="tel" data-error="Der Wert für Telefonnummer wurde nicht gesetzt">
    </div>
    <div class="help-block with-errors"></div>
  </div>
  <hr>
  <div class="form-group">
    <div class="col-sm-3 col-sm-offset-2">
      <div class="g-recaptcha" data-sitekey="..." data-callback="enableBtn"></div>
    </div>
    <div class="col-sm-6 col-sm-offset-1">
      <input type="submit" class="btn btn-primary btn-lg btn-block" id="absenden">
    </div>
  </div>
</form>
</div>
</main>
<script src="https://www.google.com/recaptcha/api.js"></script> 
<script type="text/javascript">
window.onload = document.getElementById("absenden").disabled = true;

function enableBtn(){
document.getElementById("absenden").disabled = false;
   }

从我的角度来看,一切看起来都很好。我的php脚本如下所示:

<?php 
$errors = '';
$myemail = 'maier@thermisto.com';//<-----Put Your email address here.


$product = $_POST['product'];
$colour = $_POST['colour'];
$Waermeerzeuger = $_POST['Waermeerzeuger'];
$Flaechenformat = $_POST['Flaechenformat'];
$bodenbelaege = $_POST['bodenbelaege'];
$fliesenformat = $_POST['fliesenformat'];
$montageoffer = $_POST['montage'];
$Estrich = $_POST['Estrich'];
$max_Aufbau = $_POST['max_Aufbau'];
$company = $_POST['company'];
$tax_id = $_POST['tax_id'];
$gender = $_POST['gender'];

$given_name = $_POST['given_name'];
$family_name = $_POST['family_name'];
$adress = $_POST['adress'];
$zip = $_POST['zip'];
$city = $_POST['city'];
$land = $_POST['land'];
$email_address = $_POST['email']; 
$telephone = $_POST['telephone'];




if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email_address))
{
$errors .= "\n Error: Invalid email address";
}

if(isset($_POST['submit'])){
	$headers = "From: No-Reply@thermisto.com \n"; 
$headers .= "Reply-To: $email_address";
$to = $myemail; 
$email_subject = "Inquiry form submission: $family_name, $given_name";
$email_body = "You have received a request for an offer. ".
" 
----------------------------------------------\n
Contact:\n 
Company: $company \n
Tax-ID: $tax_id \n

Gender: $gender \n
Family Name: $family_name, \n
Given Name: $given_name \n 
Adress: $adress \n
ZIP: $zip \n
City: $city \n
land: $land \n
Email: $email_address \n 
Telephone: $telephone \n

----------------------------------------------\n

Message \n 
Product/System= $product \n
Color= $colour \n
Size= $Flaechenformat \n
Waermeerzeuger= $Waermeerzeuger \n
Estrich = $Estrich\n
max. Aufbau = $max_Aufbau\n
Bodenbelag = $bodenbelaege\n
Fließenformat = $fliesenformat\n
Montageangebot = $montageoffer"; 



mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header("Location: https://www.thermisto.com/index.html");
exit();
} else {
false;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->



</body>
</html>

直播:https://www.thermisto.com/de/estrichziegel/anfordern.html(这是德语)

.htaccess文件

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{http_host} !^www\.thermisto\.com [NC]
Rewriterule ^(.*)$ http://www.thermisto.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} !www\.thermisto\.com$
RewriteRule ^(.*)$ http://www.thermisto.com/$1 [L,R=301,QSA]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


RewriteCond %{REQUEST_URI} !^/web
RewriteRule ^(.*)$ /web/$1 [NC,L]
...

其他信息可能是我使用的是SSL网站。我已经google了很多,并检查了SO。

每次我提交按钮时,我都会收到301“太可能重定向”

解决方案的提示非常好。

迎接

更新:我添加了完整的代码

0 个答案:

没有答案