Jump to content

[SOLVED] Problem with array and If statement


rilana

Recommended Posts

OK $ is gone

 

Array
(
    [job_id] => 356
    [sig] => Frau Loan Do
    [yourname] => Rilana
    [firma] => 
    [anrede] => Herr
    [adresse] => 
    [plz] => 
    [ort] => 
    [telefon] => 0764330662
    [youremail] => rila@rilana.biz
    [emailsubject] => 
    [yourmessage] => r
    [submit] => true
)

 

But error still exists.

Link to comment
Share on other sites

rightnow i am working with this.

 

$sig = $_POST['sig'] ;             // get hidden form value 

if ($sig == "Herr Colin Rhyner") {
    $myemail= "crhyner@smartpersonal.ch";
} elseif ($sig == "Frau Loan Do") {
    $myemail= "rila@rilana.biz";
} elseif ($sig == "Frau Manuela Jau") {
    $myemail= "mjau@smartpersonal.ch";	
} else {
    $myemail= "rila@freesurf.ch";
} 

 

It seems to work but only if I output $sig later.

And the new Problem I am having is that it goe's to my chunk!!!

Link to comment
Share on other sites

whole code.... why does it go to my chunkmail unstead of normal mail?

 

<?php


error_reporting(7);

// Allowed file types. Please remember to keep the format of this array, add the file extensions you want WITHOUT the dot. Please also be aware that certain file types may cause harm to your website and/or server.
$allowtypes=array("zip", "doc", "txt", "pdf", "jpg", "png", "gif");

// What's your email address? Seperate email addresses with commas for multiple email addresses.

$sig = $_POST['sig'] ;             // get hidden form value 

if ($sig == "Herr Colin Rhyner") {
    $myemail= "crhyner@smartpersonal.ch";
} elseif ($sig == "Frau Loan Do") {
    $myemail= "rila@rilana.biz";
} elseif ($sig == "Frau Manuela Jau") {
    $myemail= "mjau@smartpersonal.ch";	
} else {
    $myemail= "rila@freesurf.ch";
} 

                   


// What priority should the script send the mail? 1 (Highest), 2 (High), 3 (Normal), 4 (Low), 5 (Lowest).
$priority="3"; 

// Should we allow visitors to attach files? How Many? 0 = Do not allow attachments, 1 = allow only 1 file to be attached, 2 = allow two files etc.
$allowattach="2"; 

// Maximum file size for attachments in KB NOT Bytes for simplicity. MAKE SURE your php.ini can handel it, post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB,       1024kb = 1MB,     512kb = 1/2MB etc..
$max_file_size="2048";

// Maximum file size for all attachments combined in KB NOT Bytes! MAKE SURE your php.ini can handel it, post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB,       1024kb = 1MB,     512kb = 1/2MB etc..
$max_file_total="4096";

// Value for the Submit Button
$submitvalue=" Senden "; 

// Value for the Reset Button
$resetvalue=" löschen ";

// Default subject? This will be sent if the user does not type in a subject
$defaultsubject="Kontaktformular"; 

// Because many requested it, this feature will add a drop down box for the user to select a array of subjects that you specify below. 
// True = Use this feature, False = do not use this feature
$use_subject_drop=false;

// This is an array of the email subjects the user can pick from. Make sure you keep the format of this array or you will get errors!
// Look at http://phphq.net/forums/viewtopic.php?p=836 for examples on how to use this feature.
$subjects=array("Nachricht","Bewerbung");

// This is an array of the email address for the array above. There must be an email FOR EACH array value specified above. You can have only 1 department if you want.
//YOU MUST HAVE THE SAME AMMOUNT OF $subjects and $emails or this WILL NOT work correctly! The emails also must be in order for what you specify above!
// You can also seperate the emails by a comma to sent 1 department to multiple email addresses.
$emails=array("info@smartpersonal.ch","info@smartpersonal.ch");

// This is the message that is sent after the email has been sent. You can use html here.
// If you want to redirect users to another page on your website use this: <script type=\"text/javascript\">window.location=\"http://www.smartpersonal.ch\";</script>

$thanksmessage="Vielen Dank für Ihr email."; 
$thanksmessage="<script type=\"text/javascript\">window.location=\"http://www.smartpersonal.ch/danke.php\";</script>"; 
// Uncomment (remove the //'s) above to use redirect



/*
//================================================================================
* ! ATTENTION !
//================================================================================
: Don't edit below this line unless you know some php. Editing some variables or other stuff could cause undeseriable results!!
*/

// Will get the extension of the users file. For some reason trying to get the actual type of the file caused problems with certain browsers.

function get_ext($key) { 
$key=strtolower(substr(strrchr($key, "."), 1));
// Cause there the same right?
$key=str_replace("jpeg","jpg",$key);
return $key;
}

function phattach($file,$name) {
global $boundary;

$fp=@fopen($file,"r");
$str=@fread($fp, filesize($file));
$str=@chunk_split(base64_encode($str));
$message="--".$boundary."\n";
$message.="Content-Type: application/octet-stream; name=\"".$name."\"\n";
//$message.="Content-disposition: attachment\n"; Thanks goes to someone named Chris (I think, it was awhile ago) for his fix below!
$message.="Content-disposition: attachment; filename=\"".$name."\"\n"; 
$message.="Content-Transfer-Encoding: base64\n";
$message.="\n";
$message.="$str\n";
$message.="\n";

return $message;
}

//Little bit of security from people forging headers. People are mean sometimes 
function clean($key) {
$key=str_replace("\r", "", $key);
$key=str_replace("\n", "", $key);
$find=array(
	"/bcc\:/i",
	"/Content\-Type\:/i",
	"/Mime\-Type\:/i",
	"/cc\:/i",
	"/to\:/i"
);
  $key=preg_replace($find,"",$key);
  return $key;
}

// Safe for register_globals=on =)

$error="";
$types="";
$sent_mail=false;

// Do some loopy stuff for the valid file types so people can see what types are valid before they try and upload invalid ones.

$ext_count=count($allowtypes);
$i=0;

foreach($allowtypes AS $extension) {

//Gets rid of the last comma

If($i <= $ext_count-2) {
	$types .="*.".$extension.", ";
} Else {
	$types .="*.".$extension;
}
$i++;
}
unset($i,$ext_count); // why not


// If they post the form start the mailin'!

If($_POST['submit']==true) {
extract($_POST, EXTR_SKIP);

	// Check the form for errors

	If(trim($yourname)=="") { 
		$error.="Sie haben keinen Namen eingegeben!<br />";
	}

	If(trim($youremail)=="") { 
		$error.="Sie haben keine email eingegeben!<br />";
	} Elseif(!eregi("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$",$youremail)) {
		$error.="Invalid email address.<br />";
	}

	If(trim($emailsubject)=="") {
		$emailsubject=$defaultsubject;
	}

	If(trim($yourmessage)=="") { 
		$error.="Sie haben keine Nachricht eingegeben!<br />";
	}

	// Verify Attchment info

	If($allowattach > 0) {

		//Loopish

		For($i=0; $i <= $allowattach-1; $i++) {

			If($_FILES['attachment']['name'][$i]) {

				$ext=get_ext($_FILES['attachment']['name'][$i]);
				$size=$_FILES['attachment']['size'][$i];
				$max_bytes=$max_file_size*1024;

				//Check if the file type uploaded is a valid file type. 

				If(!in_array($ext, $allowtypes)) {

					$error.= "Die Endung Ihres Files ist nicht korrekt: ".$_FILES['attachment']['name'][$i].", only ".$types." are allowed.<br />";

					//Check the size of each file

				} Elseif($size > $max_bytes) {
					$error.= "Ihr file: ".$_FILES['attachment']['name'][$i]." ist zu gross. Maximale Grösse ist ".$max_file_size."kb.<br />";
				}

			} // If Files

		} // For

		//Tally the size of all the files uploaded, check if it's over the ammount.

  			$total_size=array_sum($_FILES['attachment']['size']);
  			
		$max_file_total_bytes=$max_file_total*1024;

		If($total_size > $max_file_total_bytes) {
			$error.="The max size allowed for all your files is ".$max_file_total."kb<br />";
		}

	} // If Allowattach

If($error) {

	$display_message=$error;

} Else {

	If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
		$subject_count=count($subjects);
		$email_count=count($emails);

		If($subject_count==$email_count) {

			$myemail=$emails[$emailsubject];
			$emailsubject=$subjects[$emailsubject];

		}

	}


	$boundary=md5(uniqid(time()));

	//Little bit of security from people forging headers. People are mean sometimes 

	$yourname=clean($yourname);
	$yourmessage=clean($yourmessage);
	$youremail=clean($youremail);
	$firma=clean($firma);

	//Headers

	$headers="From: ".$youremail."\n";
	$headers.="Reply-To: ".$youremail."\n";
	$headers.="MIME-Version: 1.0\n";
	$headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
	$headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
	$headers.="X-Mailer: PHP/".phpversion()."\n";
	$headers.="X-Priority: ".$priority."\n"; 
	$headers.="Return-Path: <".$youremail.">\n";
	$headers.="This is a multi-part message in MIME format.\n";

	//Message

	$message = "--".$boundary."\n";
	$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
	$message.="Content-Transfer-Encoding: quoted-printable\n";
	$message.="\n";
	$message.="sig: $sig";
	$message.="\n";
	$message.="job_id: $job_id";
	$message.="\n";
	$message.="Firma: $firma";
	$message.="\n";
	$message.="Anrede: $anrede";
	$message.="\n";
	$message.="Name: $yourname";
	$message.="\n";
	$message.="Adresse: $adresse";
	$message.="\n";
	$message.="PLZ: $plz";
	$message.="Ort: $ort";
	$message.="\n";
	$message.="Telefon: $telefon";
	$message.="\n";
	$message.="$yourmessage";
	$message.="\n";

	//Lets attach to something! =)

	If($allowattach > 0) {

		For($i=0; $i <= $allowattach-1; $i++) {

			If($_FILES['attachment']['name'][$i]) {

				$message.=phattach($_FILES['attachment']['tmp_name'][$i],$_FILES['attachment']['name'][$i]);

			}

		} //For

	} // If


	// End the message

	$message.="--".$boundary."--\n";

	// Send the completed message

	If(!mail($myemail,$emailsubject,$message,$headers)) {

		echo '<pre>', print_r($_POST, 1), '</pre>';

		Exit("An error has occured, please report this to the website administrator.\n");

	} Else {

		$sent_mail=true;

	}

} // Else

} // $_POST

/*
//================================================================================
* Start the form layout
//================================================================================
:- Please know what your doing before editing below. Sorry for the stop and start php.. people requested that I use only html for the form..
*/
?>
<style type="text/css">
body{
	background-color:#FFFFFF;
	font-family: Verdana, Arial, sans-serif;
	font-size: 12pt;
	color: #000000;
}

.error_message{
	font-family: Verdana, Arial, sans-serif;
	font-size: 11pt;
	color: #0D49CD;
}

.thanks_message{
	font-family: Verdana, Arial, sans-serif;
	font-size: 11pt;
	color: #000000;
}

a:link{
	text-decoration:none;
	color: #000000;
}
a:visited{
	text-decoration:none;
	color: #000000;
}
a:hover{
	text-decoration:none;
	color: #000000;
}


.table {
	border-collapse:collapse;
	border:1px solid #000000;
	width:500px;
}

.table_header{
	border:1px solid #070707;
	background-color:#0D49CD;
	font-family: Verdana;
	font-size: 11pt;
	font-weight:bold;
	color: #FFFFFF;
	text-align:center;
	padding:2px;
}

.attach_info{
background-color:#FFFFFF;
font-family: Verdana, Arial, sans-serif;
font-size: 8pt;
color: #000000;
padding:4px;
line-height: 12pt;
}


.table_body{
	border:1px solid #070707;
	background-color:#EBEBEB;
	font-family: Verdana, Arial, sans-serif;
	font-size: 10pt;
	color: #000000;
	padding:2px;
}


.table_footer{
	border:1px solid #070707;
	background-color:#C03738;
	text-align:center;
	padding:2px;
}


input,select,textarea {
	font-family: Verdana, Arial, sans-serif;
	font-size: 10pt;
	color: #000000;
	background-color:#CCCCCC;
	border:1px solid #000000;
}

.copyright {
	border:0px;
	font-family: Verdana, Arial, sans-serif;
	font-size: 9pt;
	color: #000000;
	text-align:right;
}

form{
	padding:0px;
	margin:0px;
}
#Layer6 {position:absolute;
left:0;
top:123px;
width:202px;
height:170px;
z-index:6;
visibility: visible;
}
</style>


<script type="text/javascript">
var error="";
e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;

function Checkit(theform) {

if(theform.yourname.value=="") {
	error+="Sie haben keinen Namen eingegeben\n";
}

if(theform.youremail.value=="") {
	error+="Sie haben keine E-Mail Adresse eingegeben\n";
} else if(!e_regex.test(theform.youremail.value)) {
	error+="Ihre E-Mail Adresse ist falsch\n";
}

if(theform.yourmessage.value=="") {
	error+="Sie haben keine Nachricht geschrieben\n";
}

if(theform.telefon.value=="") {
	error+="Sie haben keine Telefonnummer angegeben\n";
}

if(error) {
	alert('**Folgende Fehler sind aufgetreten:**\n\n' + error);
	error="";
	return false;
} else {
	return true;
}
}
</script>


<?If($display_message) {?>

<div align="center" class="error_message"><b><?=$display_message;?></b></div>
<br />

<?}?>

<?If($sent_mail!=true) {?>

<html>
<head>
<title>smart personal gmbh</title>
<meta name="Keywords"CONTENT="temporärstellen, dauerstellen, stellenvermittlung, kaderstellen, jobs"> 
<meta name="Description"CONTENT="smart personal vermittelt Dauer-, Temporär- und Kaderstellen aus den Bereichen Büro, Industrie, Technik und Bau."> 
<meta name="Author" CONTENT="smart personal gmbh"> 
<!--Fireworks 8 Dreamweaver 8 target.  Created Thu Mar 30 14:06:57 GMT+0200 ( ) 2006-->
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

<!--
window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
for (var i = 1; i<=10; i++) {
	if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
}
if (d) {d.style.display='block';}
}
//-->
</script>
<link href="../style.css" rel="stylesheet" type="text/css">
<link href="menu.css" rel="stylesheet" type="text/css">

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>

<body bgcolor="#FFFFFF" background="pics/line.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="javascript:montre();" onmouseout="javascript:montre();">
<div id="Layer6">
  <table width="204" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td><img src="pics/sideContact.jpg" alt="index" width="204" height="155"></td>
    </tr>
    <tr>
      <td><?
include("smart.html");
?></td>
    </tr>
  </table>
</div>
<div id="Layer1" style="position:absolute; left:0px; top:0; z-index:1; visibility: visible;">
  <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
    <tr>
      <td align="left" valign="top" bgcolor="#FFFFFF"><div align="left"><a href="http://www.smartpersonal.ch"><img src="pics/logo.gif" alt="logo" width="204" height="123" border="0"></a></div></td>
      <td width="100%" align="left" valign="top" background="pics/topAddT.jpg"><div align="left"><img src="pics/top.jpg" alt="top" width="388" height="71" border="0"></div></td>
    </tr>
  </table>
</div>
<div id="Layer2" style="position:absolute; left:258px; top:68px; z-index:2; visibility: visible;"><img src="pics/blLine.gif" width="10" height="61"></div>
<div id="Layer3" style="position:absolute; left:271px; top:105px; z-index:3; visibility: visible;"> 
  <span class="NavTitel">kontaktieren Sie uns</span>
</div>
<div id="Layer5" style="position:absolute; left:262px; top:150px; width:510px; height:168px; z-index:5; visibility: visible;">
<span class="inhaltTitel">
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>" enctype="multipart/form-data" name="phmailer" onSubmit="return Checkit(this);">
<table align="center" class="inhalt">

<?If($allowattach > 0) {?>
	<tr class="inhalt">
		<td class="attach_info" colspan="2">
            <input name="job_id" type="hidden" value="<?=stripslashes(htmlspecialchars($job_id));?>">
			<b>Mögliche Beilagen:</b> <?=$types?><br />
	  <b>Maximale Beilagengrösse:</b> <?=$max_file_size?>kb.</td>
	</tr>
<?}?>

<tr>
	<td width="24%" class="inhalt">Name / Vorname:</td>
	<td width="76%" class="inhalt"><input name="yourname" type="text" size="30" value="<?=stripslashes(htmlspecialchars($yourname));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
      <td class="inhalt">Firma:</td>
  <td class="inhalt"><input name="firma" type="text" size="30" value="<?=stripslashes(htmlspecialchars($firma));?>" />        </td>
  </tr>
  
  <tr>
      <td class="inhalt">Anrede:</td>
  <td class="inhalt"><select name="anrede" id="anrede">
                  <option>Bitte wählen Sie... </option>
                  <option value="Herr" selected>Herr</option>
                  <option value="Frau">Frau</option>
                  <option value="Firma">Firma</option>
                </select>        </td>
  </tr>
  <tr>
      <td class="inhalt">Adresse:</td>
  <td class="inhalt"><input name="adresse" type="text" size="30" value="<?=stripslashes(htmlspecialchars($adresse));?>" />        </td>
  </tr>
  
  	  <tr>
      <td class="inhalt">PLZ / Ort:</td>
  <td class="inhalt"><input name="plz" type="text" size="4" value="<?=stripslashes(htmlspecialchars($plz));?>" />
  					 <input name="ort" type="text" size="25" value="<?=stripslashes(htmlspecialchars($ort));?>" />	     </td>
  </tr>
    <tr>
      <td class="inhalt">Telefon:</td>
  <td class="inhalt"><input name="telefon" type="text" size="30" value="<?=stripslashes(htmlspecialchars($telefon));?>" /><span class="error_message">*</span></td>
  </tr>

<tr>
	<td width="24%" class="inhalt">Your Email:</td>
	<td width="76%" class="inhalt"><input name="youremail" type="text" size="30" value="<?=stripslashes(htmlspecialchars($youremail));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
	<td width="24%" class="inhalt">Betreff:</td>
	<td width="76%" class="inhalt">

		<?If($use_subject_drop AND is_array($subjects)) {?>
				<select name="emailsubject" size="1" class="inhalt">
					<?while(list($key,$val)=each($subjects)) {?>

						<option value="<?=intval($key);?>"><?=htmlspecialchars(stripslashes($val));?></option>

					<?}?>
				</select>


		<?} Else {?>

			<input name="emailsubject" type="text" class="inhalt" value="<?=stripslashes(htmlspecialchars($emailsubject));?>" size="30" />

	<?}?>		</td>
</tr>

<?For($i=1;$i <= $allowattach; $i++) {?>
<tr>
	<td width="24%" class="inhalt">Beilage senden:</td>
	<br>
	<td width="76%" class="inhalt"><input name="attachment[]" type="file" size="30" /></td><br>
</tr>
<?}?>

<tr class="inhalt">
	<td colspan="2"><span class="inhalt"><br>
    Ihre Nachricht:</span><span class="error_message">*</span><br />
		<div align="center" class="inhalt">
			<textarea name="yourmessage" rows="6" cols="60"><?=stripslashes(htmlspecialchars($yourmessage));?></textarea>
	</div>		</td>
</tr>
			<input name="sig" type="hidden" value="<?=stripslashes(htmlspecialchars($sig));?>">

<tr class="inhalt">
	<td colspan="2" align="left" class="inhalt">
		<input type="hidden" name="submit" value="true" />
		<input type="submit" value="<?=$submitvalue;?>" />  
	<input type="reset" value="<?=$resetvalue;?>" />		</td>
</tr>
<tr class="inhalt">
  <td colspan="2" align="left" class="inhalt"></td>
  </tr>

</table>
</form>

<?} Else {?>

<div align="center" class="thanks_message"><?=$thanksmessage;?></div>
<br />
<br />

<?}?>

</div>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.