PHP: simple formulario
- Johan007
- Guru


- Registrado: Sep 17, 2003
- Mensajes: 1080
- Loc: Aldershot, UK
- Status: Offline
Para esta escuela tengo un formulario de correo electrónico y hacer las obras.
Sin embargo, si algo no se ajusta a la validación de toda la información se pierde! ¿Cómo puedo mantener la información?
Sin embargo, si algo no se ajusta a la validación de toda la información se pierde! ¿Cómo puedo mantener la información?
Código: [ Select ]
<html>
<head>
<title>Web Design Quote</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="css/standard.css" rel="stylesheet">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
$error_message="All fields must be completed";
?>
<?php
if ($submit) { // if the submit button was pressed
if($name && $product ) { // if all fields were completed
// check if email syntax is valid
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
{
echo "<b>The e-mail was not valid</b>";
}
else {
mail("info@*****.com","order","$product + $message + $phone + $address + $postcode + $fax","From: $name <$email>") or die("email error");
echo "<b>Your message has been sent</b>"; // if all went well, display message was sent
} // end of is email valid or not
} // end of if all fields were completed
else {
echo "$error_message<BR>"; // if not all were filled in, display error message
}
} // end php if statement
?>
<form action="" method="post">
<p align="left">
<select name="product">
<option selected>Please Select</option>
<option>EAAS, full version £475.00</option>
<option>EAAS, Human Resources £250.00</option>
<option>EAAS, Budget module £250.00</option>
<option>EAAS, Asset Register £100.00</option>
<option>EAAS, Demo CD</option>
</select>
<br>
Your name: <br>
<input type="text" name="name">
<br>
Your email: <br>
<input type="text" name="email">
<br>
Phone number<br>
<input type="text" name="phone">
<br>
Fax number<br>
<input type="text" name="fax">
<br>
School name<br>
<input type="text" name="school">
<br>
Address<br>
<textarea name="address" cols="50"></textarea>
<br>
Postcode<br>
<input type="text" name="postcode">
<br>
Additional <br>
<textarea name="message" cols="50" rows="7"></textarea>
<br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
</body>
</html>
<head>
<title>Web Design Quote</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="css/standard.css" rel="stylesheet">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
$error_message="All fields must be completed";
?>
<?php
if ($submit) { // if the submit button was pressed
if($name && $product ) { // if all fields were completed
// check if email syntax is valid
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
{
echo "<b>The e-mail was not valid</b>";
}
else {
mail("info@*****.com","order","$product + $message + $phone + $address + $postcode + $fax","From: $name <$email>") or die("email error");
echo "<b>Your message has been sent</b>"; // if all went well, display message was sent
} // end of is email valid or not
} // end of if all fields were completed
else {
echo "$error_message<BR>"; // if not all were filled in, display error message
}
} // end php if statement
?>
<form action="" method="post">
<p align="left">
<select name="product">
<option selected>Please Select</option>
<option>EAAS, full version £475.00</option>
<option>EAAS, Human Resources £250.00</option>
<option>EAAS, Budget module £250.00</option>
<option>EAAS, Asset Register £100.00</option>
<option>EAAS, Demo CD</option>
</select>
<br>
Your name: <br>
<input type="text" name="name">
<br>
Your email: <br>
<input type="text" name="email">
<br>
Phone number<br>
<input type="text" name="phone">
<br>
Fax number<br>
<input type="text" name="fax">
<br>
School name<br>
<input type="text" name="school">
<br>
Address<br>
<textarea name="address" cols="50"></textarea>
<br>
Postcode<br>
<input type="text" name="postcode">
<br>
Additional <br>
<textarea name="message" cols="50" rows="7"></textarea>
<br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
</body>
</html>
- <html>
- <head>
- <title>Web Design Quote</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <LINK href="css/standard.css" rel="stylesheet">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <?php
- $error_message="All fields must be completed";
- ?>
- <?php
- if ($submit) { // if the submit button was pressed
- if($name && $product ) { // if all fields were completed
- // check if email syntax is valid
- if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
- {
- echo "<b>The e-mail was not valid</b>";
- }
- else {
- mail("info@*****.com","order","$product + $message + $phone + $address + $postcode + $fax","From: $name <$email>") or die("email error");
- echo "<b>Your message has been sent</b>"; // if all went well, display message was sent
- } // end of is email valid or not
- } // end of if all fields were completed
- else {
- echo "$error_message<BR>"; // if not all were filled in, display error message
- }
- } // end php if statement
- ?>
- <form action="" method="post">
- <p align="left">
- <select name="product">
- <option selected>Please Select</option>
- <option>EAAS, full version £475.00</option>
- <option>EAAS, Human Resources £250.00</option>
- <option>EAAS, Budget module £250.00</option>
- <option>EAAS, Asset Register £100.00</option>
- <option>EAAS, Demo CD</option>
- </select>
- <br>
- Your name: <br>
- <input type="text" name="name">
- <br>
- Your email: <br>
- <input type="text" name="email">
- <br>
- Phone number<br>
- <input type="text" name="phone">
- <br>
- Fax number<br>
- <input type="text" name="fax">
- <br>
- School name<br>
- <input type="text" name="school">
- <br>
- Address<br>
- <textarea name="address" cols="50"></textarea>
- <br>
- Postcode<br>
- <input type="text" name="postcode">
- <br>
- Additional <br>
- <textarea name="message" cols="50" rows="7"></textarea>
- <br>
- <input type="submit" name="submit" value="Send">
- <input type="reset" name="Reset" value="Reset">
- </p>
- </form>
- </body>
- </html>
Read my Movie Reviews punk!
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Marzo 20th, 2004, 11:58 am
- Scorpius
- Proficient


- Registrado: Mar 20, 2004
- Mensajes: 401
- Loc: Scorpion Hole
- Status: Offline
- _Leo_
- Proficient


- Registrado: Feb 17, 2004
- Mensajes: 279
- Loc: Buenos Aires, Argentina
- Status: Offline
De esta manera:
Usted tendrá que agregar una matriz para el nombre del producto, ya que lo cambié por un número del 1 al 5.
Código: [ Select ]
<html>
<head>
<title>Web Design Quote</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="css/standard.css" rel="stylesheet">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
$error_message="All fields must be completed";
?>
<?php
if ($submit) { // if the submit button was pressed
if($name && $product ) { // if all fields were completed
// check if email syntax is valid
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
{
echo "<b>The e-mail was not valid</b>";
}
else {
mail("no_spam@dot.com","order","$product + $message + $phone + $address + $postcode + $fax","From: $name <$email>") or die("email error");
echo "<b>Your message has been sent</b>"; // if all went well, display message was sent
} // end of is email valid or not
} // end of if all fields were completed
else {
echo "$error_message<BR>"; // if not all were filled in, display error message
}
} // end php if statement
?>
<form action="" method="post">
<p align="left">
<select name="product">
<option>Please Select</option>
<option value="1" <?=($product==1)?" SELECTED":""?>>EAAS, full version £475.00</option>
<option value="2" <?=($product==2)?" SELECTED":""?>>EAAS, Human Resources £250.00</option>
<option value="3" <?=($product==3)?" SELECTED":""?>>EAAS, Budget module £250.00</option>
<option value="4" <?=($product==4)?" SELECTED":""?>>EAAS, Asset Register £100.00</option>
<option value="5" <?=($product==5)?" SELECTED":""?>>EAAS, Demo CD</option>
</select>
<br>
Your name: <br>
<input type="text" name="name" value="<?=$name?>">
<br>
Your email: <br>
<input type="text" name="email" value="<?=$email?>">
<br>
Phone number<br>
<input type="text" name="phone" value="<?=$phone?>">
<br>
Fax number<br>
<input type="text" name="fax" value="<?=$fax?>">
<br>
School name<br>
<input type="text" name="school" value="<?=$school?>">
<br>
Address<br>
<textarea name="address" cols="50"><?=$address?></textarea>
<br>
Postcode<br>
<input type="text" name="postcode" value="<?=$postcode?>">
<br>
Additional <br>
<textarea name="message" cols="50" rows="7"><?=$message?></textarea>
<br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
</body>
</html>
<head>
<title>Web Design Quote</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="css/standard.css" rel="stylesheet">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
$error_message="All fields must be completed";
?>
<?php
if ($submit) { // if the submit button was pressed
if($name && $product ) { // if all fields were completed
// check if email syntax is valid
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
{
echo "<b>The e-mail was not valid</b>";
}
else {
mail("no_spam@dot.com","order","$product + $message + $phone + $address + $postcode + $fax","From: $name <$email>") or die("email error");
echo "<b>Your message has been sent</b>"; // if all went well, display message was sent
} // end of is email valid or not
} // end of if all fields were completed
else {
echo "$error_message<BR>"; // if not all were filled in, display error message
}
} // end php if statement
?>
<form action="" method="post">
<p align="left">
<select name="product">
<option>Please Select</option>
<option value="1" <?=($product==1)?" SELECTED":""?>>EAAS, full version £475.00</option>
<option value="2" <?=($product==2)?" SELECTED":""?>>EAAS, Human Resources £250.00</option>
<option value="3" <?=($product==3)?" SELECTED":""?>>EAAS, Budget module £250.00</option>
<option value="4" <?=($product==4)?" SELECTED":""?>>EAAS, Asset Register £100.00</option>
<option value="5" <?=($product==5)?" SELECTED":""?>>EAAS, Demo CD</option>
</select>
<br>
Your name: <br>
<input type="text" name="name" value="<?=$name?>">
<br>
Your email: <br>
<input type="text" name="email" value="<?=$email?>">
<br>
Phone number<br>
<input type="text" name="phone" value="<?=$phone?>">
<br>
Fax number<br>
<input type="text" name="fax" value="<?=$fax?>">
<br>
School name<br>
<input type="text" name="school" value="<?=$school?>">
<br>
Address<br>
<textarea name="address" cols="50"><?=$address?></textarea>
<br>
Postcode<br>
<input type="text" name="postcode" value="<?=$postcode?>">
<br>
Additional <br>
<textarea name="message" cols="50" rows="7"><?=$message?></textarea>
<br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
</body>
</html>
- <html>
- <head>
- <title>Web Design Quote</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <LINK href="css/standard.css" rel="stylesheet">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <?php
- $error_message="All fields must be completed";
- ?>
- <?php
- if ($submit) { // if the submit button was pressed
- if($name && $product ) { // if all fields were completed
- // check if email syntax is valid
- if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) )
- {
- echo "<b>The e-mail was not valid</b>";
- }
- else {
- mail("no_spam@dot.com","order","$product + $message + $phone + $address + $postcode + $fax","From: $name <$email>") or die("email error");
- echo "<b>Your message has been sent</b>"; // if all went well, display message was sent
- } // end of is email valid or not
- } // end of if all fields were completed
- else {
- echo "$error_message<BR>"; // if not all were filled in, display error message
- }
- } // end php if statement
- ?>
- <form action="" method="post">
- <p align="left">
- <select name="product">
- <option>Please Select</option>
- <option value="1" <?=($product==1)?" SELECTED":""?>>EAAS, full version £475.00</option>
- <option value="2" <?=($product==2)?" SELECTED":""?>>EAAS, Human Resources £250.00</option>
- <option value="3" <?=($product==3)?" SELECTED":""?>>EAAS, Budget module £250.00</option>
- <option value="4" <?=($product==4)?" SELECTED":""?>>EAAS, Asset Register £100.00</option>
- <option value="5" <?=($product==5)?" SELECTED":""?>>EAAS, Demo CD</option>
- </select>
- <br>
- Your name: <br>
- <input type="text" name="name" value="<?=$name?>">
- <br>
- Your email: <br>
- <input type="text" name="email" value="<?=$email?>">
- <br>
- Phone number<br>
- <input type="text" name="phone" value="<?=$phone?>">
- <br>
- Fax number<br>
- <input type="text" name="fax" value="<?=$fax?>">
- <br>
- School name<br>
- <input type="text" name="school" value="<?=$school?>">
- <br>
- Address<br>
- <textarea name="address" cols="50"><?=$address?></textarea>
- <br>
- Postcode<br>
- <input type="text" name="postcode" value="<?=$postcode?>">
- <br>
- Additional <br>
- <textarea name="message" cols="50" rows="7"><?=$message?></textarea>
- <br>
- <input type="submit" name="submit" value="Send">
- <input type="reset" name="Reset" value="Reset">
- </p>
- </form>
- </body>
- </html>
Usted tendrá que agregar una matriz para el nombre del producto, ya que lo cambié por un número del 1 al 5.
- Johan007
- Guru


- Registrado: Sep 17, 2003
- Mensajes: 1080
- Loc: Aldershot, UK
- Status: Offline
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 5 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 211 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
