My first script

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
rthriller
Forum Newbie
Posts: 2
Joined: Wed Mar 26, 2003 3:20 am
Location: Paris, France
Contact:

My first script

Post by rthriller »

:oops:

Hello,

Am just a beginners and this is my fist script
At the end of the script there is the line :
header("Location: envoiok2.html"
If I check one or more checkboxes of the form http://www.e2c93.asso.fr/contactentreprise.html the header function works and I am redirected to envoiok.html but if I do not check any box in the form, the mail is sent, but I am not redirect, I just get the message : Votre message a bien été envoyé

Whats wrong??

<?
function contribs($check) {
global $contr,$ii;
for ($i=0; $i<$ii; $i++) {
$contr.="
<strong>
<font color=#0000FF size=5>
&curren;
</font>
</strong>
<font color=#000000>
&nbsp".stripslashes($check[$i])."
</font>
<br>";
}
return $contr;
}
$email="rthriller@excite.com";

//contrib is an array sent by a form, it contains the status of some check boxes
//the form is here http://www.e2c93.asso.fr/contactentreprise.html
$ii=count($contrib);
if ($ii>0)
{$contr=contribs($contrib);}
else
{$contr="Aucune contribution. "."&nbsp";}


//The header of the email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$auteur." <".$auteur.">\r\n";
$headers .= "To: "."Real Thriller"." <".$email.">\r\n";
$headers .= "Reply-To: ".$auteur ." <$auteur>\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: E2C OLEANE";

//The message is an html table containing relplies to the form
$msg = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="600" border="2" cellpadding="2" cellspacing="2" bordercolor="#0000FF">
<tr bordercolor="#0000FF">
<td width="200" bgcolor="#DDFFFF">
<font color="#000000" face="Arial, Helvetica, sans-serif">
<strong>
Nom de l'
."'entreprise :
</strong>
</font>
</td>"
.'
<td width="400" bgcolor="#DDFFFF"><font color="#000000" face="Arial, Helvetica, sans-serif">'
;
$msg .= stripslashes($Entreprise);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td bgcolor="#FFFFDD">
<font face="Arial, Helvetica, sans-serif">
<strong>
Activit&eacute; de l'
."'entreprise:".'
</strong>
</font>
</td>
<td bordercolor="#0000FF" bgcolor="#FFFFDD"><font face="Arial, Helvetica, sans-serif">'
;
$msg .= stripslashes($Activite);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td bgcolor="#DDFFFF">
<font face="Arial, Helvetica, sans-serif">
<strong>
Nom du repr&eacute;sentant :
</strong>
</font>
</td>
<td bgcolor="#DDFFFF"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($Nom);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td bgcolor="#FFFFDD">
<font face="Arial, Helvetica, sans-serif">
<strong>
Fonction :
</strong>
</font>
</td>
<td bgcolor="#FFFFDD"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($Fonction);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td bgcolor="#FFFFDD">
<font face="Arial, Helvetica, sans-serif">
<strong>
T&eacute;l&eacute;phone :
</strong>
</font>
</td>
<td bgcolor="#FFFFDD"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($Telephone);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td bgcolor="#FFFFDD">
<font face="Arial, Helvetica, sans-serif">
<strong>
Fax :
</strong>
</font>
</td>
<td bgcolor="#FFFFDD"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($Fax);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td bgcolor="#DDFFFF">
<font face="Arial, Helvetica, sans-serif">
<strong>
E-mail :
</strong>
</font>
</td>
<td bgcolor="#DDFFFF"><font face="Arial, Helvetica, sans-serif"><a href="mailto:'
;
$msg .=$auteur;
$msg .='">';
$msg .=$auteur;
$msg .='</a>&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td valign="top" bgcolor="#FFFFDD">
<font face="Arial, Helvetica, sans-serif">
<strong>
Adresse :
</strong>
</font>
</td>
<td valign="top" bgcolor="#FFFFDD"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes("$Adresse \n $CodePostal $Ville");
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td valign="top" bgcolor="#DDFFFF">
<font face="Arial, Helvetica, sans-serif">
<strong>
Nombre de salari&eacute;s :
</strong>
</font>
</td>
<td valign="top" bgcolor="#DDFFFF"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($NombreSalaries);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td valign="top" bgcolor="#DDFFFF">
<font face="Arial, Helvetica, sans-serif">
<strong>
Contribution :
</strong>
</font>
</td>
<td valign="top" bgcolor="#DDFFFF"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($contr);
$msg .='&nbsp</font></td></tr>
<tr bordercolor="#0000FF">
<td valign="top" bgcolor="#DDFFFF">
<font face="Arial, Helvetica, sans-serif">
<strong>
Remarques :
</strong>
</font>
</td>
<td valign="top" bgcolor="#DDFFFF"><font face="Arial, Helvetica, sans-serif">'
;
$msg .=stripslashes($Remarques);
$msg .='&nbsp</font></td>
</tr>
</table>
<p></p>'
;
$msg .= "Adresse IP de l'expéditeur: ".$REMOTE_ADDR;
$msg .='
</body>
</html>'
;
$a=mail($email,$sujet,$msg,$headers);
if ($a==1) {
header("Location: envoiok2.html");
echo "Votre message a bien été envoyé .";
}
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please read viewtopic.php?t=1157
php produces errors and notices if it encounters problems.
By default they should be written to the webserver's log-file. Either open this file in an editor that will reload it whenever it changes or place

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
?>
at the top of each script while you're developing.
The latter will not show parse errors (because they occur before display_errors can take place) so reading the error.log is the better way.
Post Reply