kokoi
July 20, 2004, 9:36am
1
I got a script from a site, allowing to create a e-mail form with validation of the text boxes and e-mail address. But I always seem to get an error message. I think it has something to do with the
“//Relative path from this script (important)”.Now serverside scripting has never really been my thing. So that’s why I started this thread. What is meant with the line between quotation marks ?
Thnx in advance
system
July 20, 2004, 9:53am
2
What’s the error message ? What’s the script ?
system
July 20, 2004, 9:55am
3
The error message is generated by the script itself.
<?php
################################################################
# Mail-it Now! Upload2Server 1.4 #
# Script written by: Matthieu Biscay #
# Web: http://www.skyminds.net/source/ #
# Contact: http://www.skyminds.net/contact/ #
# Copyright SkyMinds.Net. All rights reserved. #
# This script is linkware. Please leave this header here. #
# For commercial use or custom version contact us. #
################################################################
// ---------------------------------- EDIT HERE --------------------------------- //
// Your email to get the results.
$dest = "[email protected] ";
//Full path to your upload dir
$up_full = "http://www.kokoi.be/upload/";
//Relative path from this script (important)
$up_dir = "/upload/";
// Number of upload fields. Put 0 if you don't want any.
$UploadNum = "0";
//Host mail functions. Possible values are 0 or 1. See below:
// 0 is for most hosts (default value).
// 1 is for Online.Net (Online).
$online_isp = "0";
// --------------------------------------------------------------------------------- //
if(isset($_REQUEST["submit"]))
{
// ------------------------ Fields Verification Process ------------------------- //
$Nada = '';
$From = $_REQUEST['From'];
$Msg = $_REQUEST['Msg'];
$Name = $_REQUEST['Name'];
if(empty($From))
{
$Nada.="Email field is empty !<br>";
}
if(empty($Msg))
{
$Nada.="Message field is empty !<br>";
}
$noway = "$Nada" ;
if(empty($Nada) &&
eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$",$From))
{
$ok = TRUE;
}
elseif(!empty($Nada) &&
eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$",$From))
{
$ok = FALSE;
}
else
{
$ml = "Your email address is invalid !<br>";
$ok = FALSE;
}
// ------------------------------------------------------------------------- //
// ----------------------------- Upload Files ------------------------------ //
$status = '';
$new_name = '';
$uploaded = '';
$get_files = '';
$all_names = '';
for($i=0;$i<count($_FILES["fileup"]["tmp_name"]);$i++)
{
$name=$_FILES["fileup"]["name"][$i];
$temp=$_FILES["fileup"]["tmp_name"][$i];
$size=$_FILES["fileup"]["size"][$i];
$type=$_FILES["fileup"]["type"][$i];
if($size > 0)
{
global $up_dir, $all_names;
$new_name = time() . "-" . $name;
$new_name = str_replace(" ","_",$new_name);
@move_uploaded_file($temp, $up_dir . $new_name);
$all_names.= "$new_name
";
}
}
// ------------------------------------------------------------------------- //
// ----------------------------- Upload Messages --------------------------- //
if(empty($all_names))
{
$status = "No files uploaded.";
$uploaded = "No files sent.";
}
else
{
$status = "File(s) successfully uploaded.";
$uploaded = "Yes !
Files:";
$get_files = "
Get the file(s): $up_full";
}
//--------------------------------------------------------------------------- //
// ----------------------------- Mail Builder ------------------------------ //
if($ok == "TRUE")
{
$referer = $_SERVER["HTTP_REFERER"];
$subject = "Feedback";
$body = "Origin: $referer
";
$body.="
***** Results *****
";
if(count($_POST))
{
while(list($key, $val) = each($_POST))
{
$body.="$key : $val
";
}
}
$body.="
";
$body.="Upload: $uploaded
";
$body.="$all_names
";
$body.="$get_files
";
$body.="*************************
";
if($online_isp == "1")
{
if(!email("feedback",$dest,$sujet,$body))
{
print "An error occured during mail delivery <br>";
}
}
else
{
if(!mail($dest, $subject, $body, "From: $Name < $From >
" . "X-Mailer: PHP/" . phpversion() ))
{
print "An error occured during mail delivery <br>";
}
}
// ------------------------------------------------------------------------- //
// ---------------------------- Success Message ---------------------------- //
?>
<html><head><title>Success !</title></head><body bgcolor="white">
<center><table width="450" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="#000000">
<table width="550" border="0" cellspacing="1" cellpadding="2"><tr>
<td colspan="2" bgcolor="#ffffff"><div align="center"><br>
Thank you !<br><br>Your message has been successfully sent to the webmaster and should receive an answer shortly.<br><br>
<?php echo $status; ?>
<br><p> </p><p> </p>
<p><a href="http://www.skyminds.net/source/">Back to the main page</a></p><br></div>
<font size="-2"><a href="http://www.skyminds.net/source/" target="_blank">Mail-it Now!</a></font>
</tr></table>
</td></tr></table></center></body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) -->
</html>
<?php
}
// ------------------------------------------------------------------------- //
else
{
// ----------------------------- Error Message ----------------------------- //
?>
<html><head><title>Error !</title></head><body bgcolor="white">
<center><table width="450" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="#000000">
<table width="550" border="0" cellspacing="1" cellpadding="2"><tr>
<td colspan="2" bgcolor="#ffffff"><div align="center"><br><b>
<?php
echo $noway;
echo $ml;
?>
</b><p><br><br>Your message could not be processed properly. Please note the error messages above and press the back button to try again.<br> If the problem still remains <a href="http://www.skyminds.net/contact/">contact the webmaster</a> to fix the problem.</p>
<p> </p><p> </p>
<p><a href='Javascript:history.go(-1)'>BACK</a></p><br></div>
<font size="-2"><a href="http://www.skyminds.net/source/" target="_blank">Mail-it Now!</a></font>
</tr></table>
</td></tr></table></center></body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) -->
</html>
<?php
// ------------------------------------------------------------------------- //
}
}
else
{
$num = 0;
$upload_box = '';
while($num < $UploadNum)
{
$num++;
$upload_box.= "<tr><td><font size='-1' face='verdana'> File $num:</font></td><td><input name='fileup[]' type='file'></td>";
}
?>
<html>
<head>
<title>Script from SkyMinds.Net (http://www.skyminds.net/)</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#003399" vlink="#003399" alink="#003399"
topmargin=" 0" leftmargin="0" marginwidth="0" marginheight="0" style="border: 1">
<!--
################################################################
# Mail-it Now! Upload2Server 1.4 #
# Script written by: Matthieu Biscay #
# Web: http://www.skyminds.net/source/ #
# Contact: http://www.skyminds.net/contact/ #
# Copyright SkyMinds.Net. All rights reserved. #
# This script is linkware. Please leave this header here. #
# For commercial use or custom version contact us. #
################################################################
-->
<table border="0" width="60%" align="center"><tr><td valign="top">
<table border="1" width="70%" bordercolor="#000000" bordercolordark="#FFFFFF" cols="1" align="center"><tr><td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<table border="0" bordercolor="#000000" height="100" align="center"><tr>
<td height="5" width="218"><font size="2" face="Arial, Helvetica, sans-serif"><b>Email : </b></font></td><td height="5" width="249"><input type="text" size="30" maxlength="255" name="From" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr><tr><td height="5" width="218"><font size="2" face="Arial, Helvetica, sans-serif">Name : </font></td><td height="5" width="249"><input type="text" size="30" name="Name" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr></table>
<p align="center"><b><font size="2" face="Arial, Helvetica, sans-serif">Message : </font></b><br><textarea name="Msg" cols="45" rows="7"></textarea><br></p>
<table width="95%" border="0" align="center"><tr align="center"><td> </td>
<?php echo $upload_box; ?></tr></table>
<p align="center"><br>
<input type="reset" name="reset" value=" Clear ">
<input type="submit" name="submit" value=" Send " style="background-color:#CCCCCC">
</p>
</form>
<font size="-2"><a href="http://www.skyminds.net/source/" target="_blank">Mail-it Now!</a></font>
</td></tr></table>
</td></tr></table>
</body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) -->
</html>
<?php } ?>
system
July 20, 2004, 10:06am
4
In the relative path you should fill in the path ‘seen’ from the location of this script. Your upload directory is http://www.kokoi.be/upload , so if you place the script on http://www.kokoi.be then the relative path is “upload/”. If you place it in http://www.kokoi.be/scripts then the relative path is “…/upload/”. What is the error message generated by the script ?
system
July 20, 2004, 10:10am
5
print "An error occured during mail delivery ";
You can find it somewhere in the middle of the script. But I don’t have a clue why it’s triggered. PHP is like chinese to me.
system
July 20, 2004, 10:20am
6
Try this. Don’t forget to change the relative path if necessary.
<?php
################################################## ##############
# Mail-it Now! Upload2Server 1.4 #
# Script written by: Matthieu Biscay #
# Web: http://www.skyminds.net/source/ #
# Contact: http://www.skyminds.net/contact/ #
# Copyright SkyMinds.Net. All rights reserved. #
# This script is linkware. Please leave this header here. #
# For commercial use or custom version contact us. #
################################################## ##############
// ---------------------------------- EDIT HERE --------------------------------- //
// Your email to get the results.
$dest = "[email protected] ";
//Full path to your upload dir
$up_full = "http://www.kokoi.be/upload/";
//Relative path from this script (important)
$up_dir = "/upload/";
// Number of upload fields. Put 0 if you don't want any.
$UploadNum = "0";
//Host mail functions. Possible values are 0 or 1. See below:
// 0 is for most hosts (default value).
// 1 is for Online.Net (Online).
// --------------------------------------------------------------------------------- //
if(isset($_REQUEST["submit"]))
{
// ------------------------ Fields Verification Process ------------------------- //
$Nada = '';
$From = $_REQUEST['From'];
$Msg = $_REQUEST['Msg'];
$Name = $_REQUEST['Name'];
if(empty($From))
{
$Nada.="Email field is empty !<br>";
}
if(empty($Msg))
{
$Nada.="Message field is empty !<br>";
}
$noway = "$Nada" ;
if(empty($Nada) &&
eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$",$From))
{
$ok = TRUE;
}
elseif(!empty($Nada) &&
eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$",$From))
{
$ok = FALSE;
}
else
{
$ml = "Your email address is invalid !<br>";
$ok = FALSE;
}
// ------------------------------------------------------------------------- //
// ----------------------------- Upload Files ------------------------------ //
$status = '';
$new_name = '';
$uploaded = '';
$get_files = '';
$all_names = '';
for($i=0;$i<count($_FILES["fileup"]["tmp_name"]);$i++)
{
$name=$_FILES["fileup"]["name"][$i];
$temp=$_FILES["fileup"]["tmp_name"][$i];
$size=$_FILES["fileup"]["size"][$i];
$type=$_FILES["fileup"]["type"][$i];
if($size > 0)
{
global $up_dir, $all_names;
$new_name = time() . "-" . $name;
$new_name = str_replace(" ","_",$new_name);
@move_uploaded_file($temp, $up_dir . $new_name);
$all_names.= "$new_name
";
}
}
// ------------------------------------------------------------------------- //
// ----------------------------- Upload Messages --------------------------- //
if(empty($all_names))
{
$status = "No files uploaded.";
$uploaded = "No files sent.";
}
else
{
$status = "File(s) successfully uploaded.";
$uploaded = "Yes !
Files:";
$get_files = "
Get the file(s): $up_full";
}
//--------------------------------------------------------------------------- //
// ----------------------------- Mail Builder ------------------------------ //
if($ok == "TRUE")
{
$referer = $_SERVER["HTTP_REFERER"];
$subject = "Feedback";
$body = "Origin: $referer
";
$body.="
***** Results *****
";
if(count($_POST))
{
while(list($key, $val) = each($_POST))
{
$body.="$key : $val
";
}
}
$body.="
";
$body.="Upload: $uploaded
";
$body.="$all_names
";
$body.="$get_files
";
$body.="*************************
";
if(!mail($dest, $subject, $body, "From: $Name < $From >
" . "X-Mailer: PHP/" . phpversion() ))
{
print "An error occured during mail delivery <br>";
}
// ------------------------------------------------------------------------- //
// ---------------------------- Success Message ---------------------------- //
?>
<html><head><title>Success !</title></head><body bgcolor="white">
<center><table width="450" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="#000000">
<table width="550" border="0" cellspacing="1" cellpadding="2"><tr>
<td colspan="2" bgcolor="#ffffff"><div align="center"><br>
Thank you !<br><br>Your message has been successfully sent to the webmaster and should receive an answer shortly.<br><br>
<?php echo $status; ?>
<br><p> </p><p> </p>
<p><a href="http://www.skyminds.net/source/">Back to the main page</a></p><br></div>
<font size="-2"><a href="http://www.skyminds.net/source/" target="_blank">Mail-it Now!</a></font>
</tr></table>
</td></tr></table></center></body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) -->
</html>
<?php
}
// ------------------------------------------------------------------------- //
else
{
// ----------------------------- Error Message ----------------------------- //
?>
<html><head><title>Error !</title></head><body bgcolor="white">
<center><table width="450" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="100%" bgcolor="#000000">
<table width="550" border="0" cellspacing="1" cellpadding="2"><tr>
<td colspan="2" bgcolor="#ffffff"><div align="center"><br><b>
<?php
echo $noway;
echo $ml;
?>
</b><p><br><br>Your message could not be processed properly. Please note the error messages above and press the back button to try again.<br> If the problem still remains <a href="http://www.skyminds.net/contact/">contact the webmaster</a> to fix the problem.</p>
<p> </p><p> </p>
<p><a href='javascript:history.go(-1)'>BACK</a></p><br></div>
<font size="-2"><a href="http://www.skyminds.net/source/" target="_blank">Mail-it Now!</a></font>
</tr></table>
</td></tr></table></center></body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) -->
</html>
<?php
// ------------------------------------------------------------------------- //
}
}
else
{
$num = 0;
$upload_box = '';
while($num < $UploadNum)
{
$num++;
$upload_box.= "<tr><td><font size='-1' face='verdana'> File $num:</font></td><td><input name='fileup[]' type='file'></td>";
}
?>
<html>
<head>
<title>Script from SkyMinds.Net (http://www.skyminds.net/)</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#003399" vlink="#003399" alink="#003399"
topmargin=" 0" leftmargin="0" marginwidth="0" marginheight="0" style="border: 1">
<!--
################################################## ##############
# Mail-it Now! Upload2Server 1.4 #
# Script written by: Matthieu Biscay #
# Web: http://www.skyminds.net/source/ #
# Contact: http://www.skyminds.net/contact/ #
# Copyright SkyMinds.Net. All rights reserved. #
# This script is linkware. Please leave this header here. #
# For commercial use or custom version contact us. #
################################################## ##############
-->
<table border="0" width="60%" align="center"><tr><td valign="top">
<table border="1" width="70%" bordercolor="#000000" bordercolordark="#FFFFFF" cols="1" align="center"><tr><td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<table border="0" bordercolor="#000000" height="100" align="center"><tr>
<td height="5" width="218"><font size="2" face="Arial, Helvetica, sans-serif"><b>Email : </b></font></td><td height="5" width="249"><input type="text" size="30" maxlength="255" name="From" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr><tr><td height="5" width="218"><font size="2" face="Arial, Helvetica, sans-serif">Name : </font></td><td height="5" width="249"><input type="text" size="30" name="Name" style="background-color: #CCCCCC;font: verdana; color: #000000; border: 0px;" value=""></td></tr></table>
<p align="center"><b><font size="2" face="Arial, Helvetica, sans-serif">Message : </font></b><br><textarea name="Msg" cols="45" rows="7"></textarea><br></p>
<table width="95%" border="0" align="center"><tr align="center"><td> </td>
<?php echo $upload_box; ?></tr></table>
<p align="center"><br>
<input type="reset" name="reset" value=" Clear ">
<input type="submit" name="submit" value=" Send " style="background-color:#CCCCCC">
</p>
</form>
<font size="-2"><a href="http://www.skyminds.net/source/" target="_blank">Mail-it Now!</a></font>
</td></tr></table>
</td></tr></table>
</body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) -->
</html>
<?php } ?>
system
July 20, 2004, 11:32am
7
I still got the error message. Could it have something do to with my server?
PS: www.kokoi.be/contact2.php
system
July 20, 2004, 11:51am
8
I tested it on my server and it worked flawlessly.
http://www.voetsjoeba.com/upload.php
It seems that your host does not allow emails to be sent.
system
July 20, 2004, 11:56am
9
Well that’s a bummer. Thnx for helping voetsjoeba.
system
July 20, 2004, 11:59am
10
Anytime. You might want to ask your host to allow email, after all email is a basic service of a host.