Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2009, 06:06
neulig
 
Fecha de Ingreso: diciembre-2009
Mensajes: 3
Antigüedad: 14 años, 5 meses
Puntos: 0
Ayuda con formulario

Hola a todos,

soy nuevo en este foro y también en la programación. Me gusta e interesa mucho PHP y en realidad todos los idiomas que nos permite la informática.

Les cuento que estoy haciendo un formulario para hacer pedidos, bastante simple, pero tengo dos grandes problemas (me imagino que para vosotros serán ínfimos), aquí van:

1.- No sé cómo validar mi formulario, es decir, si alguien no llena los campos (nombre, apellido, etc) se debería ver una alerta que me indique que debo llenar los campos dejados en blanco antes de validarlo y enviarlo a la base de datos.

2.- En el caso que la persona llene correctamente el formulario y haga su pedido. Cómo hacer para que el pedido hecho le llegue a quién lo pidió y a la vez a mi mismo a través de un mail, detallando en el mail el producto comprado, su valor neto, el impuesto y el total?

Les adjunto los archivos que he creado, espero me puedan ayudar. Muchas gracias!

Código PHP:
 formulario con los productos ya sumados en documento anterior
<form action="bestellen.php" method="post">

<?php

$_POST
['tc1k'];
$_POST['tc3k'];
$_POST['tc5k'];
$_POST['bio1f'];
$_POST['sjf'];
$_POST['tvf'];
$_POST['gesamtbetrag'];

$preis1 =   $_POST['tc1k']*9.70;
$preis2 =   $_POST['tc3k']*21.70;
$preis3 =   $_POST['tc5k']*35.70;
$preis4 =   $_POST['bio1f']*13.30;
$preis5 =   $_POST['sjf']*11.30;
$preis6 =   $_POST['tvf']*10.10;

$gesamt $preis1 $preis2 $preis3 $preis4 $preis5 $preis6;

$versandkostenpauschale $gesamt 6.9;

$gesamtbetrag $gesamt 6.9;

$preis1 number_format($preis12"," ".");
$preis2 number_format($preis22"," ".");
$preis3 number_format($preis32"," ".");
$preis4 number_format($preis42"," ".");
$preis5 number_format($preis52"," ".");
$preis6 number_format($preis62"," ".");

$versandkostenpauschale number_format($versandkostenpauschale2"," ".");
$gesamt number_format($gesamt2"," ".");
$gesamtbetrag number_format($gesamtbetrag2"," ".");


echo 
" <table  align='center'bgcolor='#FFFFCC'width='720' border='0' cellspacing='2' cellpadding='2'>
    <tr height='50'>
      <td class='text'>producto 1</td>
      <th width='100'><strong>$preis1 €</strong></th>
      <input type='hidden' name='tc1k' value='"
.$_POST['tc1k']."' />
      </tr>
      <hr align='center' width='720' size='7' color='#FF6600' />
      
    <tr height='50'>
      <td class='text'>producto 2</td>
      <th><strong>$preis2 €</strong></th>
      <input type='hidden' name='tc3k' value='"
.$_POST['tc3k']."' />
      </tr>

     <tr height='50'>
      <td class='text'>producto 3</td>
      <th><strong>$preis3 €</strong></th>
      <input type='hidden' name='tc5k' value='"
.$_POST['tc5k']."' />
      </tr>
      
     <tr height='50'>
      <td class='text'>producto 4</td>
      <th><strong>$preis4 €</strong></th>
      <input type='hidden' name='bio1f' value='"
.$_POST['bio1f']."' />
      </tr>
      
     <tr height='50'>
      <td class='text'>producto 5</td>
      <th><strong>$preis5 €</strong></th>
      <input type='hidden' name='sjf' value='"
.$_POST['sjf']."' />
      </tr>
      
     <tr height='50'>
      <td class='text'>producto 6</td>
      <th><strong>$preis6 €</strong></th>
      <input type='hidden' name='tvf' value='"
.$_POST['tvf']."' />
      </tr>
      
      <tr height='50'>
      <td><strong>Gesamtwarenwert </strong></td>
      <th><strong>$gesamt €</strong></th>
    </tr>
    
    <tr height='50'>
      <td>Versandkosten (6,90€)</td>
      <th><strong>$versandkostenpauschale €</strong></th>
    </tr>
    
    <tr height='50'>
      <td> <strong>Gesamtbetrag</strong></td>
      <th><strong>$gesamtbetrag €</strong></th>
      <input type='hidden' name='gesamtbetrag' value='"
.$_POST['gesamtbetrag']."' />
    </tr>
      </table>"
;

 
   echo 
" <table align='center'bgcolor='#8DCB41'width='720' border='0' cellspacing='2' cellpadding='2'>
   <tr>
   <td>
   <strong>Bitte überweisen Sie den Betrag in Höhe von</strong> " 
"<strong>" $gesamtbetrag "</strong>" "<strong>€</strong><br /><br />
   Konto Inhaberin: <strong> nombre</strong><br /><br />
   Konto Nr. <strong>1003333</strong><br /><br /> 
   BLZ 3342233<br /><br /> 
   banco x<br /><br />
   Verwendungszweck: Bitte Ihre Rechnungsnummer angeben.<br /><br />
   <strong>Vielen Dank für Ihre Einkauf!</strong><br /><br /> </td> </tr>
   <tr>
   <td><strong>*Alle Preise einschließlich MwSt.</strong><br /><br /><a href='formular.php'>zur&uuml;ck zum Formular</a></td>
   </tr></table>"
;
   echo 
"<br />";
    echo 
"<br />";
     echo 
"<br />";
      echo 
"<br />";
      
         
   echo 
"<hr align='center' width='825' size='7' color='#FF6600' />
   <table align='center'bgcolor='#FFFFCC'width='720' border='0' cellspacing='2' cellpadding='2'>
 <tr>
 <td><strong>Bitte Ihre Daten:</strong></td>
 </tr>
 <tr>
 <td>Anrede:</td>
 <td><select name='anrede'>
   <option name='anrede'>Anrede</option>
   <option name='frau'>Frau</option>
   <option name='herr'>Herr</option>
 </select></td>
 <td>Telefon:</td>
 <td><input name='telefon' /></td>
 </tr>
 <tr>
 <td>Nachname:</td>
 <td><input name='nachname' /></td>
 <td>E-Mail:</td>
 <td><input name='email' /></td>
 </tr>
 <tr>
 <td>Vorname:</td>
 <td><input name='vorname' /></td>
 <td>Fax:</td>
 <td><input name='fax' /></td>
 </tr>
 <tr>
 <td>Straße:</td>
 <td><input name='strasse' /></td>
 <td>PLZ:</td>
 <td><input name='plz' /></td>
 </tr>
 <tr>
 <td>Haus Nr.:</td>
 <td><input name='haus' /></td>
 <td>Ort:</td>
 <td><input name='ort' /></td>
 </tr>
 <tr>
 <td>Land:</td>
 <td><select name='land'>
   <option>Deutschland</option>
   <option>Österreich</option>
   <option>Schweiz</option>
   <option>Liechtenstein</option>
   <option>Spanien</option>
   <option>Italien</option>
   <option>Frankreich</option>
   <option>Belgien</option>
   <option>Niederlande</option>
   <option>Dänemark</option>
   <option>Andere</option>
 </select></td>
 <td>Sonstiges:</td>
 <td><textarea name='sonstiges' cols='50' rows='5'></textarea></td>
 </tr>
 <tr>
 <td class='agb'>Ich habe die AGB gelesen und akzeptiert</td>
 <td><input name='agb' type='checkbox' value='agb' checked /></td>
 </tr>
 
 <tr>
 <td><input name='abschicken' type='submit' value='Bestellung abschicken' /> <input type='button' name='drucken' value='drucken' onclick='window.print();'></td>
 </tr>
 

</table>"
;



?>
</form>