[Linux] required field

Szu-ching Peckner linux@flux.org
Tue, 21 May 2002 14:04:03 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_7902_3ad5_7213
Content-Type: text/plain; format=flowed

i have two php scripts, downloading from hotscripts.com. form.php is the one 
i am using now for my contact form. Now i need to make all fields in my 
contact form as required. so i found antoher one (contact.php) which has 
required field feature. I like to take the required field portion on 
contact.php, and paste to form.php. But the problem is I don't have 
programing background, and I tried to paste here and there, but didn't work. 
Can someone help?
Please excuse me if I am not supposed to attach files. Thanks, Szu-ching



_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com

------=_NextPart_000_7902_3ad5_7213
Content-Type: text/html; name="form.php"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="form.php"

<?php


function file2go2($url){ print "<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"0;URL=$url\">\n</head>\n</html>"; exit; }



if(!@fopen($F_TEMPLATE, "r")) file2go2($F_NOTSENT);
else $arr_t1 = @file( $F_TEMPLATE ); $nr_mail = 1;
if (! $F_TEMPLATE2 == "" && !@fopen($F_TEMPLATE2, "r")) file2go2($F_NOTSENT); 
if (! $F_TEMPLATE2 == "" &&  @fopen($F_TEMPLATE2, "r")) $arr_t2 = @file( $F_TEMPLATE2 ); $nr_mail = 2;

$domail = 1;	
while ($domail <= $nr_mail):
	if ($domail == 1) $var2use = $arr_t1; else $var2use = $arr_t2;

		for ($index = 0; $index < count($var2use); $index++)
			{
			$pattern = ereg("{{[A-z0-9_]*}}", $var2use[$index]);
			if  ($pattern)
				{
				$line = ereg_replace("{{","$",$var2use[$index]);
				$line = ereg_replace("}}","",$line);
				}
			else 
				{
				$line = $var2use[$index];
				}		
				$line = addslashes($line) . "<br>";
				eval( "\$line = \"$line\";" );
				if ($index == 0 && $domail == 1) $linetot1 = $line;
				elseif ($index > 0 && $domail == 1) $linetot1 .= $line;
				if ($index == 0 && $domail == 2) $linetot2 = $line;
				elseif ($index > 0 && $domail == 2) $linetot2 .= $line;
			}

	++$domail;
	
endwhile;
	


//the next line will email the 1st template to $F_TO of your form (normally yourself c.q. the owner of website)
$mailit1 = @mail($F_TO, $F_SUBJECT, $linetot1, "From: $F_FROM \nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit"); 

//the next (optional) line will email the sender if he filled in his email in the form:
//change the $email to the variable name in your form (the email adress of the visitor)
//only do this when you want 2 templates emailed. Otherwise put two slashes in front of the next line ( // )
//ALSO: if you want to be able to reply directly to the sender, then change $F_FROM in the next line to $email.
if ($nr_mail == 2) $mailit2 = @mail($email, $F_SUBJECT, $linetot2, "From: $F_FROM\nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit");

//if you encounter problems with html-formatting of the mail then remove the following in the appropraite 2 lines above:
//\nMime-Version: 1.0\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 7bit 
//do not remove the    ");    after that!

if ($mailit1 = true) $sent = 1;
else $sent = 0;

if ($mailit2 = true) $sent = 2;
else $sent = 0;


if ($nr_mail == 1 && $sent == 1) file2go2($F_SENT);  
if ($nr_mail == 1 && $sent == 0) file2go2($F_NOTSENT); 
if ($nr_mail == 2 && $sent == 2) file2go2($F_SENT); 
if ($nr_mail == 2 && $sent == 0) file2go2($F_NOTSENT); 



?>


------=_NextPart_000_7902_3ad5_7213
Content-Type: text/plain; name="contact.php"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="contact.php"

<?
################################################################
# Mail-it Now! Upload2Server 1.0			#
# Script written by: Matthieu Biscay		#
# E-Mail: mbiscay@skyminds.net			#
# Web: http://www.skyminds.net/			#
#					###################
# Copyright (c) 2002 SkyMinds.Net. All rights reserved.			#
# This script is free as long as this header stays in here.			#
# For commercial use or custom versions: mbiscay@skyminds.net		#
################################################################

// ---------------------------------- EDIT HERE 
--------------------------------- //
$dest = "speckner@inside.ventuer.com";	// Where the email should go...
$up_full = "http://www.domaine.com/upload/";	//Full path to your upload dir 
(not important)
$up_dir = "upload/";			//Relative path to your upload dir from this script 
(very important)
$UploadNum = "3";  			// Number of upload fields. Put 0 if you don't want 
any.

$online_isp = "0"; 			//Host mail functions. Possible values are 0,1 or 2. 
See below:

// 0 is for most hosts (default value).
// Put 1 if Online.Net is your host.
// Put 2 if Nexenservices is your host.
// 
--------------------------------------------------------------------------------- 
//

if($submit){
// ------------------------ Fields Verification Process 
------------------------- //
$Nada="";
	if (empty($From)){
    $Nada.="<center><b>name is empty !"."<BR></center></b>";    }
	if (empty($Msg)){
    $Nada.="<center><b>Message field is empty !"."<BR></center></b>";    }
$noway = "$Nada" ;
	if (empty($Nada) && 
ereg(".+(@.+)(\.[[:alpha:]]{2}([[:alpha:]]?))$",$From)){
	$ok=1;	}
	elseif ($Nada="<center><b>Message field is empty !"."<BR></center></b>" && 
ereg(".+(@.+)(\.[[:alpha:]]{2}([[:alpha:]]?))$",$From)){
	$ok=false;	}
	else{
	$ml= "<div align=center><B>Your email address is invalid !</B></div>";
	$ok=false;	}
// ------------------------------------------------------------------------- 
//

// ----------------------------- Upload Files ------------------------------ 
//
$num = 0;
$uploaded = "";
$uploaded = "No files sent.";

while($num < $UploadNum){
	$num++;

	$fichier = "fileup$num"."_name";
	$fichier1 = $$fichier;
	$fichier2 = "fileup$num";
	$fichier3 = $$fichier2;

	if($fichier3 != "none"){
		$new_fichier1 = "";
		$new_fichier1 = time() . "-" . $fichier1;
		$new_fichier1 = eregi_replace(' ','_',$new_fichier1);
		copy($fichier3, $up_dir . $new_fichier1);
		$status="";
		$status="Your files have been successfully uploaded.";
		$uploaded = "";
		$uploaded = "Yes !";
		$new_upfile_name = "";
		$new_upfile_name = $new_fichier1;
		}

	}
//---------------------------------------------------------------------------------------


// ----------------------------- Mail Builder ------------------------------ 
//
	if($ok){
$referer= getenv("HTTP_REFERER");
$sujet= "Feedback";
$body.="Origin: $referer\n";
$body.="\n***** Results *****\n";

if(count($HTTP_POST_VARS)){
    while (list($key, $val) = each($HTTP_POST_VARS)){
       $body.="$key : $val\n";
    }
}

if(count($HTTP_GET_VARS)){
    while (list($key, $val) = each($HTTP_GET_VARS)){
      $body.="$key : $val\n";
    }
}

  $body.="\n";
$body.="Upload: $uploaded\n";
$body.="File name: $new_upfile_name\n";
$body.="Get it: $up_full$new_upfile_name\n";
$body.="\n";
$body.="*************************\n";

if ($online_isp == "1"){
	if(!email("feedback",$dest,$sujet,$body)){
	print "An error occured during mail delivery <br>"; }
	}
elseif ($online_isp == "2"){
    include "mail.inc";
    if(!email($dest,$sujet,$body)){
    print "An error occured during mail delivery <br>"; }
    }
else{
	if(!mail($dest,$sujet,$body)){ print "An error occured during mail delivery 
<br>"; }
	}
// ------------------------------------------------------------------------- 
//


// ---------------------------- Success Message ---------------------------- 
//
?>
<html><head><title>This is a script from SkyMinds.Net 
(http://www.skyminds.net/)</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>
<? echo $status; ?>
<p>&nbsp;</p><p>&nbsp;</p>
<p><a href="http://www.skyminds.net/">Back to the main page</a></p><br>
</div>
<font size="-2"><a href="http://www.skyminds.net/source/">Mail-it Now! 
Upload2Server 1.0</a></font>
</TR>
</TABLE></TD>
</TR>
</TABLE></CENTER></body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/ 
Copyright 2001-2002) --></html>
<?
}
// ------------------------------------------------------------------------- 
//

else{
// ----------------------------- Error Message ----------------------------- 
//
?>
<html><head><title>This is a script from SkyMinds.Net 
(hhtp://www.skyminds.net/)</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><?
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 
me</a> to fix the problem.</p>
<p>&nbsp;</p><p>&nbsp;</p>
<p><a href='Javascript:history.go(-1)'>BACK</a></p><br>
</div>
<font size="-2"><a href="http://www.skyminds.net/source/">Mail-it Now! 
Upload2Server 1.0</a></font>
</TR>
</TABLE></TD>
</TR>
</TABLE></CENTER>
</body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/ 
Copyright 2001-2002) --></html>
<?
// ------------------------------------------------------------------------- 
//
}
}
else {
$num = 0;
while($num < $UploadNum) {
$num++;
$html .= "<TR><TD><FONT SIZE=-1 FACE=Verdana>File 
$num:</FONT></TD><TD><INPUT NAME=\"fileup$num\" TYPE=\"file\"></TD>";
}
?>
<html>
<head>
<title>This is a 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" &lt;BODY MARGINWIDTH="0"
MARGINHEIGHT="0" style="border: 1 solid #000000">
<!--
################################################################
# Mail-it Now! Upload2Server 1.0			#
# Script written by: Matthieu Biscay		#
# E-Mail: mbiscay@skyminds.net			#
# Web: http://www.skyminds.net/			#
#					###################
# Copyright (c) 2002 SkyMinds.Net. All rights reserved.			#
# This script is free as long as this header stays in here.			#
# For commercial use or custom versions: mbiscay@skyminds.net		#
################################################################
-->
<div align="center">
<table border="0" width="520"><tr>
<td valign="top">
<div align="center">
<table border="1" width="80%" bordercolor="#000000" 
bordercolordark="#FFFFFF" cols="1">
<tr><td>
<form action='<?echo $PHP_SELF?>' method="post" 
enctype="multipart/form-data">
<table border="0" bordercolor="#000000" height="100"><tr>
<td height="5" width="218"><strong><font size="2" face="Arial, Helvetica, 
sans-serif">Email</font></strong><font size="2" face="Arial, Helvetica, 
sans-serif">:</font></td>
<td height="5" width="249"><font size="3" face="Times New Roman">
<input type="text" size="30" maxlength="255" name="From" 
style="background-color: #CCCCCC;font: verdana; color: #000000; border: 
0px;">
</font></td>
</tr><tr>
<td height="5" width="218"><font size="2" face="Arial, Helvetica, 
sans-serif">Nom/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;">
</td></tr></table>
<p align="center"><b><font size="2" face="Arial, Helvetica, 
sans-serif">Message :</font></b><br>
<textarea name="Msg" cols="50" rows="12"></textarea>
<br>
</p>
<table width='95%' border='0'><tr><td><center>
<input type='hidden' name='MAX_FILE_SIZE' value='2000000'>
</center>
</td><?php echo $html; ?></tr></table>
<br><br>
<p align="center">
<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/">Mail-it Now! 
Upload2Server 1.0</a></font>
</td></tr></table>
</div>
</td></tr></table>
</div>
</body>
<!--This script sources from SkyMinds.Net (http://www.skyminds.net/) 
Copyright 2002) -->
</html>
<?
} ?>

------=_NextPart_000_7902_3ad5_7213--