Need help with MailForm.php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Marco van Wijngaarden
Forum Commoner
Posts: 59
Joined: Mon Jul 07, 2003 6:48 am
Location: The Netherlands

Need help with MailForm.php

Post by Marco van Wijngaarden »

Hi,

I am trying to get this to work:

1. i've created a HTML form which send it's results (variables) to a resultpage for the user to review it's input

2. the result page has html design and writes the variables using PHP

---- so far everything works! ----

now i need a php script to do the next two things on submit:

3. write an original number to the variables as reference
4. send the results to my email address and cc the results to the users emailaddress (this is one of the variables)
i don't know if it will be possible to send the results including html design (i.e. as attached html along with the email or as html-based email?)
5. after submit redirect to a new html page

thanks for your help!
Marco
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Could we see the code you've got so far? We're quite happy to help you with problems you're having with your own code but we aren't going to write the script for you.

Mac
User avatar
Marco van Wijngaarden
Forum Commoner
Posts: 59
Joined: Mon Jul 07, 2003 6:48 am
Location: The Netherlands

Post by Marco van Wijngaarden »

Okay, as you wish, you can find my code below!
The problem i am still strugling with is the fact that none of the variables is send! (i assume you understand that i am quite new to PHP and learning from every step) you won't need to write my code, however some directions will be more than welcome!

--------------------- my code -----------------------

<html>
<head>
<title>Bestelling</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
if ($IsVerzonden) {
if ($MailAan) {
if (mail($MailAan, $Onderwerp, $Tekst, "From: $emailadres")) {
print ("<B><CENTER><FONT COLOR=BLUE>Uw e-mail is met succes verzonden!</FONT></CENTER></B>\n");
} else {
print ("<B><CENTER><FONT COLOR=RED>Uw e-mail is niet met succes verzonden wegens een systeemfout!</FONT></CENTER></B>\n");
}
} else {
print ("<B><CENTER><FONT COLOR=RED>Geef a.u.b. het e-mail adres van de ontvanger op!</FONT></CENTER></B>\n");
}
}
?>
<script language="JavaScript">
<!--
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
</head>
<form name="form1" method="post" action="MailOrder.php">
<table width="100%" border="2" cellspacing="5" cellpadding="5" background="Images/Handen.jpg">
<tr align="center" valign="middle" bgcolor="#006600">
<td colspan="2"><font size="3" face="Arial, Helvetica, sans-serif" color="#FFFFFF">
<?php
/* deze pagina ontvangt en verwerkt de door "HandleForm.php" gegenereerde gegevens. */
print ("<B>ORDERNUMMER: </B><BR>");
print ("<B>$ordernummer</B><BR>");
?>
</font> </td>
</tr>
<tr>
<td bordercolor="#000000" valign="top" align="left">
<?php
print ("<B>Klantgegevens:</B><BR>\n");
print ("<BR>\n");
print ("$bedrijfsnaam<BR>\n");
print ("$voornaam $tussenvoegsel $achternaam<BR>\n");
print ("$straat_huisnr<BR>\n");
print ("$postcode $woonplaats, $land<BR>\n");
print ("<BR>\n");
print ("Telefoon $telefoon<BR>\n");
print ("E-mail $emailadres<BR>\n");
print ("<BR>\n");
print ("Afleveradres: $afleveradres<BR>\n");
?>
</td>
<td width="50%" bordercolor="#000000" valign="top" align="left">
<?php
print ("<B>Gegevens t.b.v. huisstijl zijn:</B><BR>\n");
print ("<BR>\n");
print ("<B>$regel1</B><BR>\n");
print ("<BR>\n");
print ("$regel2<BR>\n");
print ("$regel3<BR>\n");
print ("$regel4<BR>\n");
print ("$regel5<BR>\n");
print ("<BR>\n");
print ("$regel6<BR>\n");
print ("$regel7<BR>\n");
print ("$regel8<BR>\n");
print ("$regel9<BR>\n");
?>
</td>
</tr>
<tr align="center" valign="top">
<td bordercolor="#000000" colspan="2">
<div align="center"><font face="Arial, Helvetica, sans-serif" size="3"><b>
<?php
print ("<B>De bestelling betreft het volgende:</B><BR>\n");
print ("<BR>\n");
?>
</b></font></div>
<table width="90%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td align="right" valign="top" width="100">
<p><i><font size="1">Aantal</font></i></p>
<p>
<?php
if ($artikel1) {
print ("<B>$aantal1</B><BR>\n");
}
if ($artikel2250) {
print ("<B>$aantal2250</B><BR>\n");
}
if ($artikel2500) {
print ("<B>$aantal2500</B><BR>\n");
}
if ($artikel3500) {
print ("<B>$aantal3500</B><BR>\n");
}
if ($artikel31000) {
print ("<B>$aantal31000</B><BR>\n");
}
if ($artikel4500) {
print ("<B>$aantal4500</B><BR>\n");
}
if ($artikel41000) {
print ("<B>$aantal41000</B><BR>\n");
}
if ($artikel5250) {
print ("<B>$aantal5250</B><BR>\n");
}
if ($artikel5500) {
print ("<B>$aantal5500</B><BR>\n");
}
if ($artikel51000) {
print ("<B>$aantal51000</B><BR>\n");
}
if ($artikel6) {
print ("<B>$aantal6</B><BR>\n");
}
if ($artikel7) {
print ("<B>$aantal7</B><BR>\n");
}
?>
</p>
</td>
<td align="left" valign="top">
<p><font size="1"><i>Omschrijving</i></font></p>
<p>
<?php
if ($artikel1) {
print ("<B>$artikel1</B><BR>\n");
}
if ($artikel2250) {
print ("<B>$artikel2250</B><BR>\n");
}
if ($artikel2500) {
print ("<B>$artikel2500</B><BR>\n");
}
if ($artikel3500) {
print ("<B>$artikel3500</B><BR>\n");
}
if ($artikel31000) {
print ("<B>$artikel31000</B><BR>\n");
}
if ($artikel4500) {
print ("<B>$artikel4500</B><BR>\n");
}
if ($artikel41000) {
print ("<B>$artikel41000</B><BR>\n");
}
if ($artikel5250) {
print ("<B>$artikel5250</B><BR>\n");
}
if ($artikel5500) {
print ("<B>$artikel5500</B><BR>\n");
}
if ($artikel51000) {
print ("<B>$artikel51000</B><BR>\n");
}
if ($artikel6) {
print ("<B>$artikel6</B><BR>\n");
}
if ($artikel7) {
print ("<B>$artikel7</B><BR>\n");
}
?>
</p>
<div align="right"> </div>
</td>
<td valign="top" align="right" width="100">
<p><font size="1"><i>Bedrag</i></font></p>
<p>
<?php
if ($artikel1) {
$prijs1 = $artikelprijs1;
print ("EUR ");
printf ("%01.2f", $prijs1);
print ("<BR>\n");
}
if ($artikel2250) {
$prijs2250 = $artikelprijs2250;
print ("EUR ");
printf ("%01.2f", $prijs2250);
print ("<BR>\n");
}
if ($artikel2500) {
$prijs2500 = $artikelprijs2500;
print ("EUR ");
printf ("%01.2f", $prijs2500);
print ("<BR>\n");
}
if ($artikel3500) {
$prijs3500 = $artikelprijs3500;
print ("EUR ");
printf ("%01.2f", $prijs3500);
print ("<BR>\n");
}
if ($artikel31000) {
$prijs31000 = $artikelprijs31000;
print ("EUR ");
printf ("%01.2f", $prijs31000);
print ("<BR>\n");
}
if ($artikel4500) {
$prijs4500 = $artikelprijs4500;
print ("EUR ");
printf ("%01.2f", $prijs4500);
print ("<BR>\n");
}
if ($artikel41000) {
$prijs41000 = $artikelprijs41000;
print ("EUR ");
printf ("%01.2f", $prijs41000);
print ("<BR>\n");
}
if ($artikel5250) {
$prijs5250 = $artikelprijs5250;
print ("EUR ");
printf ("%01.2f", $prijs5250);
print ("<BR>\n");
}
if ($artikel5500) {
$prijs5500 = $artikelprijs5500;
print ("EUR ");
printf ("%01.2f", $prijs5500);
print ("<BR>\n");
}
if ($artikel51000) {
$prijs51000 = $artikelprijs51000;
print ("EUR ");
printf ("%01.2f", $prijs51000);
print ("<BR>\n");
}
if ($artikel6) {
$prijs6 = $aantal6 * $artikelprijs6;
print ("EUR ");
printf ("%01.2f", $prijs6);
print ("<BR>\n");
}
if ($artikel7) {
$prijs7 = $aantal7 * $artikelprijs7;
print ("EUR ");
printf ("%01.2f", $prijs7);
print ("<BR>\n");
}
?>
</p>
<p>&nbsp;</p>
<div align="right"></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bordercolor="#000000">
<div align="right"><font size="1" face="Arial, Helvetica, sans-serif">Door
uw bestelling......</font></div>
</td>
<td width="50%" bordercolor="#000000">
<table width="90%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td align="right" valign="top">
<?php {
print ("Subtotaal");
} {
print ("<BR>\n");
print ("Verzendkosten");
} {
print ("<BR>\n");
print ("19% BTW");
} {
print ("<BR>\n");
print ("<B>Totaal</B>");
}
?>
</td>
<td align="right" width="100" valign="top">
<?php
{
$subtotaal = $prijs1 + $prijs2250 + $prijs2500 + $prijs3500 +

$prijs31000 + $prijs4500 + $prijs41000 + $prijs5250 +

$prijs5500 + $prijs51000 + $prijs6 + $prijs7;
}
{
print ("EUR ");
printf ("%01.2f", $subtotaal);
}
if ($subtotaal <= ($verzendkostendrempel)) {
$verzendkosten = $verzendkosten_laag;
}
else {
$verzendkosten = $verzendkosten_hoog;
} {
print ("<BR>\n");
print ("EUR ");
printf ("%01.2f", $verzendkosten);
} {
$btw = ($subtotaal + $verzendkosten) * $btwpercentage;
print ("<BR>\n");
print ("EUR ");
printf ("%01.2f", $btw);
} {
$totaalbedrag = $subtotaal + $verzendkosten + $btw;
} {
print ("<BR>\n");
print ("<B>EUR ");
printf ("%01.2f", $totaalbedrag);
print ("</B>");
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div align="center">
<INPUT TYPE=HIDDEN NAME="MailAan" VALUE="marco@desteegh.nl">
<input type="hidden" name="IsVerzonden" value="TRUE">
<font size="2" face="Arial, Helvetica, sans-serif">
<input type="button" name="Button" value="Terug" onClick="MM_callJS('history.back(1)')">
<input type="button" name="Button" value="Afdrukken" onClick="MM_callJS('window.print()')">
<input type="submit" value="Verzend uw bestelling" name="send">
</font> </div>
</form>
<p align="center">&nbsp;</p>
</body>
</html>
User avatar
Marco van Wijngaarden
Forum Commoner
Posts: 59
Joined: Mon Jul 07, 2003 6:48 am
Location: The Netherlands

Post by Marco van Wijngaarden »

but first things first... is there a possiblity to grab the entire result from this php page (including HTML design) when the form on this page is submitted? My idea is to mail this as a HTML file...

Secondly, i am trying to figure out how i can keep the variables, right now i seem to loose them when i go to a second php form action, should i do that with use of cookies?

:?
Post Reply