Bestellformular

RuthG

Mitglied
Hallo,

ich grübel schon länger über ein Problem und zwar möchte ich in meinem Formular eine Zeile duplizieren um mehrere Artikeln eingeben zu können.
Jetzt hab ich in diesem Forum ein Script gefunden welches schon nah dran kommt.

Leider hupft die Zeile ganz an das Ende des Formulars. Wie kann man das ändern?
Das nächste Problem wäre dann wie bekomme ich die Daten in das Mail welches am Ende verschickt wird?

Das ist das Formular:
http://www.rundesache.cc/order.php

Danke, LG
Ruth

Jetzt ist mir noch was aufgefallen. Es wird der Text mit dupliziert, wenn schon einer eingegeben wurde. Seltsamerweise aber nicht vom ersten Feld (Units) ?
 
Das ist mein Formular:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">

<HEAD>
  <META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Win">
  <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=iso-8859-1">
  <TITLE>how to order lasers, laser crystals, Nd:YAG, Nd:YVO4, Yb:YAG, Nd:YLF, Cr:Ruby, Ti:Sapphire, Nd:YAP, KTP, BBO, CLBO, KNbO3, Ni:KNbO3, KDP, DKDP, LiNbO3, Fe:LiNbO3, Mg:LiNbO3, Nd:Mg:LiNbO3, Cr:LiNbO3, LiTaO3,BaTiO3, Rh:BaTiO3</TITLE>
  <META NAME="Description" CONTENT="laser diode,laserdiode,laserdiode,laser diodes,laserdioden,laser crystal,laser module,lasermodul,high power,GaN,GaAs,GaAlAs,optic,Laser,laser,lllt,transceiver,photo diode,photodiode,980nm pointer,UV pointer,370nm pointer,security,ktp,bbo,nd:yag,nd:yvo4">
  <META NAME="KeyWords" CONTENT="laser diode,laserdiode,visible laser,infrared laser,infrared LED,blue led,gren led,370nm,532nm,645nm,680nm,690nm,9mm,5.6mm,650nm,660nm,635nm,670nm,750nm,735nm,780nm,808nm,830nm,850nm,980nm,1064nm,840nm,1550nm,1310nm,GaN,mid-ir,uv,VCSEL,vcsel,fiber,fiber optic,UV LED,980nm pointer,green laser pointer">
  <META NAME="Author" CONTENT="ROITHNER LASERTECHNIK, Andreas Roithner">
  <LINK HREF="aa.css" REL="styleSheet" TYPE="text/css">
  
  <style type="text/css">
  
  p { line-height:130%;  margin-top:5px}
  
  .abstandvor {margin-top: 20px;}

  #payment li {margin-left:15px; list-style:circle; color:#FF0000; font-weight:bold; margin-top:5px}

  #payment img {margin-right: 20px}
  
  form { line-height:150%}
  
  h3 small { font-size:0.7em}
  
  value .feld { font-size: 0.5em; color:#CCCCCC}
  
  form { margin-top:50px}
  
  table { margin:0; padding:0; text-align:left; width:880px}
  
  table td {margin: 0; padding:0; margin-left:5px; font-size:1.2em; color: #9999cc; vertical-align:top}
  
  thead {font-size:1.2em; color: #9999cc}
  
  legend { padding: 3px; color:#9999cc; font-weight:bold; background-color:#FFFFFF}
  
  fieldset { padding:10px; margin-bottom:20px; width:880px; border: 1px dotted #999999}
  
  label { cursor:pointer; }
  
  .button { background-image:url(pic/button_klein.jpg); width:110px; height:28px; color:#FFFFFF; font-weight:bold; margin-right:20px; margin-top:20px; border:0; cursor: pointer;
}

.button_zeile { width:32px; height:32px; margin-top: -3px; margin-left: 5px; background-image:url(pic/button_zeile.jpg); background-repeat:no-repeat; border:0; cursor:pointer; color:#FFFFFF; background-color:#FFFFFF; vertical-align:middle; text-align:center}

  #personal .feld { width:420px; height:16px}
  
  .feld {border:1px #9999cc solid;  margin-bottom:5px;  vertical-align:middle; padding:2px; }	
  
  .checkbox { margin-right:5px; border:1px #9999cc solid; margin-left: 5px}
  
  #units { width:70px; margin-right:20px}
  #article { width:400px; margin-right:20px}
  #note { width:300px; }
  
  #order li { display: block; float:left; margin-right:27px}
  
  .imp {color: #191970}
  
  </style>
  
<script type="text/javascript">
<!--
function clone_this(objButton)
{
if(objButton.parentNode)
    {
    tmpNode=objButton.parentNode.cloneNode(true);
    objButton.form.appendChild(tmpNode);
    for(j=0;j<objButton.form.lastChild.childNodes.length;++j)
        {
        if(objButton.form.lastChild.childNodes[j].type=='text')
            {
            objButton.form.lastChild.childNodes[j].value='';
            break;
            }
        }
    objButton.value="-";
    objButton.onclick=new Function('f1','this.form.removeChild(this.parentNode)');
    }
}
//-->
</script>
  
</HEAD>
<BODY>
<div id="mittig">
<div id="breadcrump"><a href="index.htm">Home</a> / Order</div>
<h1>Request an order or offer</h1>
<p>If you need some more details or you need advice, please fill out the form below or call our <a href="contact">technical sales assistants</a>.</p>
<p>You already know what you need? Please fill out this form also, but tell us your payment details and the required adress. We do not accept orders by phone!</p>
<p class="abstandvor imp"><b>* These are the most important information to handle your request! </b></p>

<div id="formular">
    <form action="formular.php" method="post" onsubmit="window.open('about:blank','popup','width=700,height=500,left=250,top=250'); setTimeout('document.Kontakt.reset();', 1000);return true;" name="Kontakt" target="popup">
            
      <fieldset>
      <legend>Personal details</legend>
  			<table id="personal">  
  			<tr><td class="imp"><input type="radio" class="checkbox" name="who" value="privat"/>Private person or 
  			  <input type="radio"class="checkbox" name="who" value="company"/>
  			  Company *</td>
              <td class="imp">Have you already ordered from us?<input type="radio" class="checkbox" name="customer" value="yes"/>Yes 
  			  <input type="radio"class="checkbox" name="customer" value="no"/>
  			  No *</td>
            </tr>    
              
            <tr><td><h4><label for="company">Company name:</label></h4>
            <p><input class="feld" id="trade" type="text" name="company" size="50" maxlength="150"/></p>
            <p><input class="feld" id="trade" type="text" name="company_extra" size="50" maxlength="150"/></p></td>
            
            <td><h4><label for="number">Customer Number (if at hand): </label></h4>
            <p><input class="feld" id="trade" type="text" name="number" size="50" maxlength="150"/></p></td></tr>
                       
            
            <tr><td>
            <h4 class="imp"><label for="phone">Phone Number: *</label></h4>
            <p><input class="feld" type="text" name="phone" size="50" maxlength="150" /></p>
            <h4><label for="fax">Fax Number:</label></h4>
            <p><input class="feld" type="text" name="fax" size="50" maxlength="150" /></p></td>
            
            <td><h4 class="imp"><label for="name">Contact person (name, surname): *</label></h4>
            <p><input class="feld"  id="name" type="text" name="name" size="50" maxlength="150" /></p>
            <h4 class="imp"><label for="mail">E-mail: *</label></h4>
            <p><input class="feld" id="mail" type="text" name="mail" size="50" maxlength="150" /></p></td></tr>
            
            <tr><td><h4>Billing address:</h4>
            <p><input class="feld" type="text" name="bill_street" size="50" maxlength="150" value="street name & number" /></p>
            <p><input class="feld" type="text" name="bill_add" size="50" maxlength="150" value="" /></p>
            <p><input class="feld" type="text" name="bill_city" size="50" maxlength="150" value="city" /></p>
            <p><input class="feld" type="text" name="bill_country" size="50" maxlength="150" value="country" /></p>
            <p><input class="feld" type="text" name="bill_zip" size="50" maxlength="150" value="zip" /></p>
            <h4 class="imp">VAT only for European Customer:*</h4>
            <p><input class="feld" type="text" name="vat" size="50" maxlength="150"/>
            </td>
            

           <td><h4>Shipping address: <small>(If it is different to the billing adress.) </small></h4>
            <p><input class="feld" type="text" name="ship_street" size="50" maxlength="150" value="street name & number" /></p>
            <p><input class="feld" type="text" name="ship_add" size="50" maxlength="150" value="" /></p>
            <p><input class="feld" type="text" name="ship_city" size="50" maxlength="150" value="city" /></p>
            <p><input class="feld" type="text" name="ship_country" size="50" maxlength="150" value="country" /></p>
            <p><input class="feld" type="text" name="ship_zip" size="50" maxlength="150" value="zip" /></p></td></tr>
      </table>
      </fieldset>   
             
             <fieldset>
             <legend>Order</legend>
                        
             
             <ul id="order"><li id="units">Units</li><li id="article">Article</li><li id="note">Note</li></ul>
             <div class="clear"><input id="units" class="feld" type="text" name="units" size="7" maxlength="7" />
             <input id="article" class="feld" type="text" name="article" size="80" maxlength="100" />
             <input id="note" class="feld" type="text" name="note" size="60" maxlength="100" />
             <input type="button" class="button_zeile" value="+" onclick="clone_this(this)"></div>
             
             
             
             
             <div id="payment">
              		 <h3 class="abstandvor">Your preferred payment method</h3>
                     <p><input type="radio" class="checkbox" name="pay" value="creditcard"/>Creditcard 
                     <input type="radio"class="checkbox" name="pay" value="advanced"/>in Advance by banktransfer
               <input type="radio"class="checkbox" name="pay" value="cheques"/>Cheques</p>
                     
               		 <p class="abstandvor">We accept credit card payment with</p>
                     <p class="abstandvor"><img src="pic/logo_visa.jpg"alt="Visa"><img src="pic/logo_mc.jpg" alt="MasterCard"><img src="pic/logo_amex.jpg" alt="Amex"></p>
                     <p class="abstandvor">For payment by credit card please send us the following information <b>by fax (0043 586 52 43 44)</b> <br> or by e-mail <a href="mailto:office@roithner-laser.com">office@roithner-laser.com</a>:</p>
                     <p>Cardnumber, name of cardholder, expirationdate, security code (from the backside of your card)</p>
             </div>
             
             <div class="abstandvor">Would you like to pay in <input type="radio" class="checkbox" name="currency" value="EUR"/>EUR or <input type="radio" class="checkbox" name="currency" value="EUR"/>USD?</div>
                     
                     <h3 class="abstandvor"><label for="shipping" >Preferred shipping method</label></h3>
                     <p>We ship worldwide by  FedEx, UPS, DHL, EMS, parcel post or with any other parcel service. Please tell us you prefered courier and your courier account number.</p>
             <p><input id="shipping" class="feld" type="text" name="shipping" size="115" maxlength="150"></p>
                     
                     <p>We do accept orders on our terms and conditions only</p>
                     
              </fieldset>     
            	
      		<fieldset>
            <legend class="imp">Message *</legend>
      		<textarea  id="message" class="feld" name="message" rows="5" cols="115" wrap="soft"></textarea>
            </fieldset>
            
			<fieldset>
            <p>This is  <input type="radio" class="checkbox" name="what" value="order"/>an <b>order</b> or<input type="radio" class="checkbox" name="what" value="request"/> a <b>request</b></p>
            
            <p class="abstandvor"><input class="checkbox" type="checkbox" name="condition" value="accept">Please, click here to accept the <a href="conditions.pdf">terms and conditions.</a>*</p>    
      		<p> <input type="submit" class="button" name="senden" value="Send" />
	  			<input type="reset" class="button" name="reset" value="Reset" /></p>
            </fieldset>
            
            </form></div><!-- Ende Formular -->


    
  
                
              

</div>

</BODY>
</HTML>

und das ist die Auswertung:

PHP:
<?
$fehler ="";
$nz = chr(13);
$who = $_POST['who'];
$customer= $_POST['customer'];
$company = $_POST['company'];
$name= $_POST['name'];
$number= $_POST['number'];
$phone= $_POST['phone'];
$fax= $_POST['fax'];
$mail= $_POST['mail'];
$bill_street= $_POST['bill_street'];
$bill_city= $_POST['bill_city'];
$bill_country= $_POST['bill_country'];
$bill_zip= $_POST['bill_zip'];
$ship_street= $_POST['ship_street'];
$ship_city= $_POST['ship_city'];
$ship_country= $_POST['ship_country'];
$ship_zip= $_POST['ship_zip'];
$units= $_POST['units'];
$article= $_POST['article'];
$note= $_POST['note'];
$message= $_POST['message'];
$pay= $_POST['pay'];
$shipping= $_POST['shipping'];
$what= $_POST['what'];
$condition= $_POST['condition'];

if (empty($who)) $fehler .= "<li>Please, fill if you are a private person or a company. </li>";
if (empty($customer)) $fehler .= "<li>Please, check if you have already ordered from us.</li>";
if (empty($name)) $fehler .= "<li>Please, fill in your name. </li>";
if (empty($phone)) $fehler .= "<li>Please, fill in your phone number. </li>";
if (empty($mail)) $fehler .= "<li>Please, fill in your mail adress. </li>";
if (empty($message)) $fehler .= "<li>Please, tell us how we can help you. The Messagebox is empty. </li>";
if (empty($what)) $fehler .= "<li>Please, tell us if this is a order or a request. </li>";
if (empty($condition)) $fehler .= "<li>Please, read our conditions and check the box. </li>";
if (empty($fehler)) {

	$an = "name@mail.com";
	$betreff = "Subject: " .$what .", " .$company ." " .$name;
	$from = "From: " .$company ." " .$name  ."<" .$mail .">\n";
	$from .= "Reply-To: " .$mail ."\n";
	$from .= "Content-Type: text/html\n";
	$datum = "Datum: ".date("j.n.Y").$nz;
	$zeit = "Zeit: ".date("H:i").$nz;
	$von = "Von: ".$name."<".$mail.">".$nz;
	$bill_adress = "<p><b>Billing Adress:</b> ".$bill_street .", " .$bill_city .", " .$bill_country .", " .$bill_zip ."</p>";
	$ship_adress = "<p><b>Shipping Adress:</b> ".$ship_street .", " .$ship_city .", " .$ship_country .", " .$ship_zip ."</p>";
	$message = "<p><b>Message:</b> " .$message ."</p>";
	$what = "<p><b>Order or Request:</b> " .$what ."</p>";
	$condition = "<p><b>Condition:</b> " .$condition ."</p>";
	$personal = "<p><b>Company or Privat: </b>" .$who ."</p> <p><b>Already customer?</b> ".$customer ."</p> <p><b>Customer Number:</b> " .$number ."</p><p><b>Company: </b>" .$company  ."</p><p><b>Name:</b> " .$name ."</p><p><b>Mail:</b> " .$mail ."</p> <p><b>Phone:</b> " .$phone ."</p> <p><b>Fax:</b> " .$fax ."</p>" .$bill_adress .$ship_adress;
	$order = "<p><b>Order:</b> " .$units ." / " .$article ." / " .$note ."</p>";
	$text='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
    $text.='<html>';
    $text.='<head>';
    $text.='</head>';
    $text.='<body>';
    $text.="<p>$datum $zeit </p><p> $personal</p> <p><b>Payment: </b>$pay</p> <p><b>Shipping: </b> $shipping </p><p> $order </p><p>$message </p><p> $what $condition</p>";
    $text.='</body>';
    $text.='</html>'; 
	$titel = "Thank you for your $what. You will get a confirmation within the next days.";
	
	mail($an,$betreff,$text,$from);
	} else $titel = "Sorry, but there is a mistake.";
	?>



<html>
	
	<style type="text/css">
	body {
	font-family: Verdana, Georgia, Arial, Helvetica, sans-serif;
	font-size: 1em;
	text-align:left;
	margin-top:20px;}
	
	p { margin-bottom:5px;}
	
	br {margin-bottom: 10px}
	
	</style>
    
	<head>
	<title><?=$titel?></title>
	</head>
    
	<body>
	<?
	if (empty($fehler)) {
		$text = strip_tags($text);
		$text = htmlentities($text);
		$text = str_replace($nz,"<br>",$text);
		echo "<p>Thank you for your request/order! You will get a confirmation within the next days.</p>";
		echo "<p>$datum $zeit </p><p> $personal</p> <p><b>Payment: </b>$pay</p> <p><b>Shipping: </b> $shipping </p><p> $order </p><p>$message </p><p> $what $condition</p>";
	}	else {
		echo "<p>Sorry, your message could not be send:";
		echo "<ul>$fehler</ul>";
		echo "</p>";
		
	}
	?>
	
	</body>
	</html>
 
Code:
<ul id="order"><li id="units">Units</li><li id="article">Article</li><li id="note">Note</li></ul>
             <div class="clear"><input id="units" class="feld" type="text" name="units" size="7" maxlength="7" />
             <input id="article" class="feld" type="text" name="article" size="80" maxlength="100" />
             <input id="note" class="feld" type="text" name="note" size="60" maxlength="100" />
             <input type="button" class="button_zeile" value="+" onclick="clone_this(this)"></div>
Diesen Abschnitt kopierst Du (nur den div-Bereich) in Deiner Funktion und haengst ihn dann an das darunter liegende tag ran. Da aber alle anderen nachfolgenden Tags ebenfalls in diesem tag eingeordnet sind, liegen sie in der gleichen Ebene und appendChild haut die geklonte Node ans Ende. Hier waere es sinnvoll eine kleine Anpassung zu machen:

Code:
<div>
             <ul id="order"><li id="units">Units</li><li id="article">Article</li><li id="note">Note</li></ul>
             <div class="clear"><input id="units" class="feld" type="text" name="units" size="7" maxlength="7" />
             <input id="article" class="feld" type="text" name="article" size="80" maxlength="100" />
             <input id="note" class="feld" type="text" name="note" size="60" maxlength="100" />
             <input type="button" class="button_zeile" value="+" onclick="clone_this(this)"></div>
</div>
 
Hi,

oder das Script etwas anpassen:
Code:
function clone_this(objButton){
  if(objButton.parentNode){
    tmpNode=objButton.parentNode.cloneNode(true);
    objButton.parentNode.parentNode.insertBefore(tmpNode, objButton.parentNode.nextSibling);

    for(j=0;j<objButton.form.lastChild.childNodes.length;++j){
      if(objButton.form.lastChild.childNodes[j].type=='text'){
        objButton.form.lastChild.childNodes[j].value='';
        break;
      }
    }

    objButton.value="-";
    objButton.onclick = function(){
      this.parentNode.parentNode.removeChild(this.parentNode);
    }
  }
}

Informationen zum Versenden von Mail mittels der PHP-Funktion mail findest du hier.

Beim Drübersehen ist mir aufgefallen, dass du offensichtlich die Mail-Adressen noch nicht angepasst hast. Weiterhin solltest du eine MIME-Version angeben.

Im optionalen vierten Argument ist es ansonsten üblich, zusätzlich Headerangaben durch CRLF (\r\n) zu trennen - Ausnahmen z.B. bei qmail.

Sonst sind mehr Informationen notwendig, was funktioniert und was nicht.

Ciao
Quaese
 
Also das ist ja schon mal super :) Das Problem mit der Position ist gelöst.
Wie bekomm ich nun aber die zusätzlichen Artikel in mein Mail?

Danke
 
Hi,

versieh die Namen in den entsprechenden Input-Elementen mit leeren eckigen Klammern:
Code:
<div class="clear">
  <input id="units" class="feld" type="text" name="units[]" size="7" maxlength="7" />
  <input id="article" class="feld" type="text" name="article[]" size="80" maxlength="100" />
  <input id="note" class="feld" type="text" name="note[]" size="60" maxlength="100" />
  <input type="button" class="button_zeile" value="+" onclick="clone_this(this)">
</div>

Auf der Serverseite kannst du diese anschliessend als Arrays behandeln. Am Beispiel der units:
Code:
if(is_array($_POST['units'])){
  $units = "";
  foreach($_POST['units'] as $key => $entry){
    $units .= "Menge Artikel " . $key . ": " . $entry . "<br>";
  }
}else{
  $units= $_POST['units'];
}

Ciao
Quaese
 
Hallo noch mal,

das hat ja schon mal super funktioniert. Danke!!
Eine Frage hätte ich noch. Wenn ich jetzt mehrere Produkte eingebe dann sieht das zb so aus:

Units0: 23
Units1: 24
Units2: 25
/ Articel0: RLT 123
Articel1: RLT 879
Articel2: RLT 654
/ Note0: irgendwas
Note1: irgendwie
Note2: irgendwo

bisschen unpraktisch zum "auslesen".

Habe wirklich rumprobiert und versucht die zusammengehörigen Angaben ein einer Zeile auszugeben und erst für das nächste Produkt eine neue Zeile, habe es aber nicht geschafft.

Was muss ich da machen?

Danke schon mal, LG Ruth
 
Hi,

durchlaufe das Array ($_POST['units']) mit Hilfe einer for-Schleife. Den Zählindex verwendest du auch für den Zugriff auf die anderen übergebenen Arrays (article, note).
Code:
if(is_array($_POST['units'])){
  $units = "";
  for($i=0; $i<count($_POST['units']); $i++){
    $units .= "- " . $_POST['units'][$i] . " Einheiten " . $_POST['article'][$i] . " (" . $_POST['note'][$i] . ")<br />";
  }
}else{
  $units= "- " . $_POST['units'] . " Einheiten " . $_POST['article'] . " (" . $_POST['note'] . ")";
}

Ciao
Quaese
 

Neue Beiträge

Zurück