Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-16-2008, 04:47 AM   PM User | #1
Pastrulo
New to the CF scene

 
Join Date: Jan 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Pastrulo is an unknown quantity at this point
generate output

Is it posible to generate an output in a confirmation page for this form and have it e-mail to my e-mail and the input e-mail(custom computer creator) I created? something like a table with 3 colums: 1 price 2: product and 3: my prices..and show the total at the end. is it? I'm really new to php but maybe this is my choice..


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Arme Su Computadora!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
#wrap {
width:810px;

}

span {
float:right;
background-color:#CCCCCC;
color:blue;
width:200px;
display:inline;
text-align:center;
font-weight:bold;

}

legend {
	font-weight: bold;
}

img {
float:left;
}

input {
	float:left;
}

fieldset {
	float:right;
	width: 600px;
	padding: 5px;
	margin-right: 4px;
}

#clear {
	clear:both;
}

#pro {
width:300px;
}

</style>
</head>

<SCRIPT language="javascript">
function cent(amount) {
return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function calculate() {
var p1, p2, p3 , p4;
var test = document.forms.test;
p1 = test.precio1.value * 1;
p2 = test.precio2.value * 1;
p3 = test.precio3.value * 1;
p4 = test.precio4.value * 1;

precio_total = p1 + p2 + p3 + p4 ;
test.precio_total.value = cent(Math.round(precio_total*Math.pow(10,2))/Math.pow(10,2));
}

</SCRIPT>
<body>
<div id="wrap">
<div>  <img src="images/baner.png"> </div>

<form name="test" method="post" action="confirm.php">

<fieldset>
<legend>Datos del Cliente:</legend>
<div id="clear">Nombre:<input type="text" name="Nombre:" ></div>
<div id="clear">Correo Electrónico:<input type="text" name="Correo Electronico:" ></div>
<div id="clear">Telefono:<input type="text" name="Telefono:" ></div>
</fieldset>


<div>
<div id="clear"><img style="padding-top:30px" src="images/windows-vista.png" name="sistemas" title="sistemas" /></div>
<fieldset >
<legend>Sistemas Operativos:</legend>
<div id="clear"><table><tr><td id="pro"><input name="1" type="radio" value="Windows XP Home" onclick="this.form.precio1.value='1733.00';calculate();"><strong><font color="blue">Windows XP Home</font></strong></td> <td id="pre"><span>
			(Lps. 1733.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="1" type="radio" value="Windows XP Profesional" onclick="this.form.precio1.value='2962.00';calculate();"><strong><font color="blue">Windows XP Profesional</font></strong></td><td id="pre"> <span>(Lps. 2962.00)</span></td><br /></tr></table></div>
<tr><td><input type="hidden" name="precio1"></td></tr>
</fieldset><br />

</div>


<div>
<div id="clear"><img style="padding-top:30px" src="images/procesador.gif" name="Procesadores" title="Procesadores" /></div>
<fieldset>
<legend>Procesadores</legend>
<div id="clear"><table ><tr><td id="pro"><input name="2" type="radio" value="Procesador Intel Celeron 420 de 1,6 Ghz" onclick="this.form.precio2.value='990.00';calculate();"><strong><font color="blue">Procesador Intel Celeron 420 de 1,6 Ghz </font></strong></td> <td id="pre"><span>(Lps.990.00)</span></td><br /></tr>
</table></div>
<div id="clear"><table ><tr><td id="pro"><input name="2" type="radio" value="Procesador Pentium IV 3,0 Ghz" onclick="this.form.precio2.value='1735.00';calculate();"><strong><font color="blue">Procesador Pentium IV 3,0 Ghz </font></strong></td> <td id="pre"><span>(Lps.1735.00)</span></td><br /></tr>

</table></div>
<div id="clear"><table ><tr><td id="pro"><input name="2" type="radio" value="Procesador Intel Pentium Dual Core E2140 1,66 Ghz" onclick="this.form.precio2.value='1735.00';calculate();"><strong><font color="blue">Procesador Intel Pentium Dual Core E2140 1,66 Ghz </font></strong></td> <td id="pre"><span>(Lps.1735.00)</span></td></td><br /></tr>
</table></div>
<div id="clear"><table ><tr><td id="pro"><input name="2" type="radio" value="30" onclick="this.form.precio2.value='3180.00';calculate();"><strong><font color="blue">Procesador Intel Pentium Core 2 DUO E4400 2,0 Ghz </font></strong></td> <td id="pre"><span>(Lps.3180.00)</span></td><br /></tr>
</table></div>
<input type="hidden" name="precio2">
</fieldset><br />
</div>

<div>
<div id="clear"><img style="padding-top:30px" src="images/discoduro.png" name="Disco Duro" title="Disco Duro" /></div>

<fieldset >
<legend>Disco Duro</legend>
<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco 80 GB" onclick="this.form.precio3.value='1007.00';calculate();"><strong><font color="blue">Disco 80 GB </font></strong></td> <td id="pre"><span>(Lps.1007.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco Duro 160 GB - ide" onclick="this.form.precio3.value='12190.00';calculate();"><strong><font color="blue">Disco Duro 160 GB - ide </font></strong></td> <td id="pre"><span>(Lps.1219.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco Duro 160 GB - sata 2" onclick="this.form.precio3.value='1338.00';calculate();"><strong><font color="blue">Disco Duro 160 GB - sata 2 </font></strong></td> <td id="pre"><span>(Lps.1338.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco Duro 250GB - ide" onclick="this.form.precio3.value='1555.00';calculate();"><strong><font color="blue">Disco Duro 250GB - ide </font></strong></td> <td id="pre"><span>(Lps.1555.00)</span></td><br /></tr></table></div>

<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco Duro 320GB - sata" onclick="this.form.precio3.value='2144.00';calculate();"><strong><font color="blue">Disco Duro 320GB - sata </font></strong></td> <td id="pre"><span>(Lps.2144.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco Duro 250GB SATA " onclick="this.form.precio3.value='1860.00';calculate();"><strong><font color="blue">Disco Duro 250GB SATA </font></strong></td> <td id="pre"><span>(Lps.1860)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="3" type="radio" value="Disco Duro 400GB IDE" onclick="this.form.precio3.value='3492.00';calculate();"><strong><font color="blue">Disco Duro 400GB IDE </font></strong></td> <td id="pre"><span>(Lps.3492)</span></td><br /></tr></table></div>
<input type="hidden" name="precio3">
</fieldset><br />
</div>

<div>

<div id="clear"><img style="padding-top:30px" src="images/monitor.png" name="Monitores" title="Monitores" /></div><br />
<fieldset>
<legend>Monitores</legend>
<div id="clear"><table><tr><td id="pro"><input name="4" type="radio" value="Monitor Lcd 17' Dell" onclick="this.form.precio4.value='3945.00';calculate();"><strong><font color="blue">Monitor Lcd 17" Dell </font></strong></td> <td id="pre"><span>(Lps.3945.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="4" type="radio" value="Monitor Lcd 19' Dell " onclick="this.form.precio4.value='5151.00';calculate();"><strong><font color="blue">Monitor Lcd 19¨ Dell  </font></strong></td> <td id="pre"><span>(Lps.5151.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="4" type="radio" value="Monitor Flat Panel 15' Soyo" onclick="this.form.precio4.value='2969.00';calculate();"><strong><font color="blue">Monitor Flat Panel 15" Soyo </font></strong></td> <td id="pre"><span>(Lps.2969.00)</span></td><br /></tr></table></div>
<div id="clear"><table><tr><td id="pro"><input name="4" type="radio" value="Monitor Elite crt 15 Pulgadas" onclick="this.form.precio4.value='1437.00';calculate();"><strong><font color="blue">Monitor Elite crt 15 Pulgadas  </font></strong></td> <td id="pre"><span>(Lps.1437.00)</span></td><br /></tr></table></div>

<div id="clear"><table><tr><td id="pro"><input name="4" type="radio" value="30" onclick="this.form.precio4.value='1798.00';calculate();"><strong><font color="blue">Monitor  CRT 17¨ compaq No logo / AOC / LG</font></strong></td> <td id="pre"><span>(Lps.1798.00)</span></td><br /></tr></table></div>
<input type="hidden" name="precio4">
</fieldset><br />
</div>




<div>
<fieldset style="position:relative;top:36px;width:500px;">
<div id="clear"><p><strong><font size="5">Total:</font></strong> 
	<input type="textfield" name="precio_total"></p></div>
<div id="clear"><input type="reset" value="Borrar" onClick="" /><input style="float:right" type="submit" value="continuar" /></div>
</fieldset>
</div>

</form>



</div>    

</body>
</html>

Last edited by Pastrulo; 01-16-2008 at 06:12 AM..
Pastrulo is offline   Reply With Quote
Old 01-16-2008, 09:14 AM   PM User | #2
daemonkin
Regular Coder

 
Join Date: Jun 2007
Location: N. Ireland
Posts: 351
Thanks: 16
Thanked 4 Times in 4 Posts
daemonkin is on a distinguished road
Formatting an output for email is quite tricky as some (especially webmail) programs will strip out all or some HTML tags including your doc type ref if included.

I use a custom built function called buildEmail() that accepts a number of parameters such as an array of fields to use in email, the max email width - typically 70 characters and anything else to be included.

When I have created emails in the past I always found difficulty using \n\r to break but soon realised that creating a string using:

PHP Code:
$str 'text\n\rtext' 
will ignore the formatting so you will need to use "" for your string.

You can build up an HTML email and include tables such as:

PHP Code:
$str "<html>";
$str .= "<body>";
$str .="<table><tr><td>";
$str .= $some_content."</td></tr></table></body></html>";

$headers  'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' "\r\n";
// Mail it
$to 'someone@somewhere.net';
$subject 'Some subject';
mail($to$subject$str$headers); 
For more information check out mail()
__________________
Daemonkin.
If this was helpful, please add to my reputation
Thousand Sons - Freelance Web Developer - ninetyonedegrees.com
daemonkin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:49 AM.


Advertisement
Log in to turn off these ads.