Problem med php mail funktion

Diskussion av datorer, inte bara i rent tekniska aspekter utan även i politiska och filosofiska.

Moderator: Moderatorgrupp

PatrikIden
Ny medlem
Ny medlem
Inlägg: 1
Blev medlem: 2011-11-14 00:28

Problem med php mail funktion

Inlägg av PatrikIden » 2011-11-14 00:32

Hej jag kommer bara till error.php sidan när jag klickar på Svara på detta inlägg knappen på denna sida som jag håller på att bygga.
Här är koden:

Kod: Markera allt

<?php 
$errorpage = 'true'; 
session_start();

if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
  if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt']) { 
    unset($_POST['captcha_code'],$_SESSION['random_txt']); 
  } 
  else { if ($errorpage == 'false') {
    echo '<b>Fel kod!</b><br>'; 
    echo '<a href="javascript:history.back()">Försök igen!</a>'; 
    exit; 
  } if ($errorpage == 'true')  { 
    header('Location: ././error.php'); 
  exit; 
  } 
}
}  
?><?php
   function ValidateEmail($email)
   {
      $pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
      return preg_match($pattern, $email);
   }

   if($_SERVER['REQUEST_METHOD'] == 'POST')
   {
      $mailto = 'patrik@fcab.se';
      $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
      $subject = 'Svar på Jobbförfrågan från Jobler.se';
      $message = 'Kategori';
      $success_url = './tack.php';
      $error_url = './error.php';
      $error = '';
      $eol = "\n";
      $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
      $boundary = md5(uniqid(time()));

      $header  = 'From: '.$mailfrom.$eol;
      $header .= 'Reply-To: '.$mailfrom.$eol;
      $header .= 'MIME-Version: 1.0'.$eol;
      $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
      $header .= 'X-Mailer: PHP v'.phpversion().$eol;
      if (!ValidateEmail($mailfrom))
      {
         $error .= "The specified email address is invalid!\n<br>";
      }

      if (!empty($error))
      {
         $errorcode = file_get_contents($error_url);
         $replace = "##error##";
         $errorcode = str_replace($replace, $error, $errorcode);
         echo $errorcode;
         exit;
      }

      $internalfields = array ("submit", "reset", "send", "captcha_code");
      $message .= $eol;
      $message .= "IP Address : ";
      $message .= $_SERVER['REMOTE_ADDR'];
      $message .= $eol;
      foreach ($_POST as $key => $value)
      {
         if (!in_array(strtolower($key), $internalfields))
         {
            if (!is_array($value))
            {
               $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
            }
            else
            {
               $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
            }
         }
      }

      $body  = 'This is a multi-part message in MIME format.'.$eol.$eol;
      $body .= '--'.$boundary.$eol;
      $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
      $body .= 'Content-Transfer-Encoding: 8bit'.$eol;
      $body .= $eol.stripslashes($message).$eol;
      if (!empty($_FILES))
      {
          foreach ($_FILES as $key => $value)
          {
             if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize)
             {
                $body .= '--'.$boundary.$eol;
                $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
                $body .= 'Content-Transfer-Encoding: base64'.$eol;
                $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
                $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
             }
         }
      }
      $body .= '--'.$boundary.'--'.$eol;
      mail($mailto, $subject, $body, $header);
      header('Location: '.$success_url);
      exit;
   }
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>De 6 Senatse Uppdragsförfrågningarna</title>
<meta name="generator" content="WYSIWYG Web Builder - http://www.wysiwygwebbuilder.com">
<style type="text/css">
div#container
{
   width: 1280px;
   position: relative;
   margin-top: 0px;
   margin-left: auto;
   margin-right: auto;
   text-align: left;
}
</style>
<style type="text/css">
body
{
   text-align: center;
   margin: 0;
   background-color: #FFFFFF;
   background-image: url(images/bg-pattern.png);
   color: #000000;
}
</style>
<script type="text/javascript" src="./jquery-1.4.2.min.js"></script>
<style type="text/css">
a 
{
  -moz-outline: none 0;
  outline: none 0;
}
</style><style type="text/css">
#NavigationBar1 ul.navbar
{
   list-style: none;
   margin: 0;
   padding: 0;
}
#NavigationBar1 ul.navbar li
{
   height: 59px;
   width: 200px;
   float: left;
   margin: 0px 4px 0px 0px;
}
#NavigationBar1 ul.navbar li a
{
   display: block;
   position: relative;
}
#NavigationBar1 ul.navbar li a img
{
   position: absolute;
   z-index: 1;
   border-width: 0px;
}
#NavigationBar1 ul.navbar li span
{
   display: block;
   height: 59px;
   width: 200px;
   position: absolute;
   z-index: 2;
}
</style>
<style type="text/css">
#SlideMenu1 ul
{
   list-style: none;
   margin: 0;
   padding: 0;
   font-family: Arial;
   font-size: 13px;
}
#SlideMenu1 li
{
   cursor: pointer;
}
#SlideMenu1 li div
{
   margin: 0px 0px 0px 0px;
   padding: 2px 2px 2px 5px;
   background-color: #0C94DE;
   position: relative;
   left: 0;
   top: 0;
   width: 239px;
}
#SlideMenu1 li div:hover
{
   background-color: #0C94DE;
}
#SlideMenu1 li a
{
   color: #FFFFFF;
   font-weight: bold;
   text-decoration: none;
}
#SlideMenu1 li a:hover
{
   color: #FFFFFF;
   font-weight: bold;
   text-decoration: none;
}
#SlideMenu1 li li
{
   cursor: auto;
   padding: 2px 2px 2px 5px;
   margin: 1px 0px 1px 0px;
   background-color: #F7F7F7;
}
#SlideMenu1 li li a
{
   color: #387AC8;
   font-weight: normal;
   text-decoration: none;
}
#SlideMenu1 li li:hover
{
   background-color: #EDF5FD;
}
#SlideMenu1 li li a:hover
{
   color: #387AC8;
   font-weight: normal;
   text-decoration: none;
}
</style>
<script type="text/javascript">
$(document).ready(function()
{
   $("#NavigationBar1 .navbar a").hover(function()
   {
      $(this).children("span").hide();
   }, function()
   {
      $(this).children("span").show();
   })
   $(".SlideMenu1_Folder div").click(function()
   {
      if ($(this).parent().find('ul').is(':hidden'))
      {
         $(this).parent().find('ul').show();
      }
      else
      {
         $(this).parent().find('ul').hide();
      }
   });
});
</script>
</head>
<body>
<div id="Layer2" style="position:absolute;text-align:center;background-image:url(images/bg-header.png);background-repeat:repeat-x;;background-position:center center;left:0px;top:0px;width:100%;height:16px;z-index:30" title="" 
>
<div id="Layer2_Container" style="width:1280px;position:relative;margin-left:auto;margin-right:auto;text-align:left;">
</div>
</div><div id="container">

<div id="wb_Shape1" style="margin:0;padding:0;position:absolute;left:314px;top:690px;width:652px;height:48px;text-align:center;z-index:32;">
<img src="images/senaste6_0009.png" id="Shape1" alt="" title="" style="border-width:0;width:652px;height:48px"></div>
<div id="Html2" style="position:absolute;left:488px;top:705px;width:46px;height:25px;z-index:33">
<?
$databasename='****'; // Name of the database
$tablename='****'; // Name of the table
$mysqladd='****'; // Address to the MySQL Server - Usually localhost but could be an IP address
$mysqluser='****'; // Your MySQL UserName
$mysqlpass='****'; // Your MySQL Password


//CONNECT TO MYSQL
$link=mysql_connect($mysqladd, $mysqluser, $mysqlpass) or die('Could not connect to database: ' . mysql_error());

//CONNECT TO DATABASE
mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error());

$result = mysql_query("SELECT * FROM jobadd"); 
$num_rows = mysql_num_rows($result);  // Display the results echo $num_rows; 

echo "<font face='Arial' font color=##13A4E3>$num_rows</font>";

?> </div>
<div id="wb_Text16" style="margin:0;padding:0;position:absolute;left:327px;top:706px;width:172px;height:16px;text-align:left;z-index:34;">
<font style="font-size:13px" color="#B92F00" face="Arial">Aktiva förfrågningar just nu:</font><font style="font-size:13px" color="#FFFFFF" face="Arial"> </font></div>
<div id="wb_senShape21" style="margin:0;padding:0;position:absolute;left:313px;top:166px;width:654px;height:574px;text-align:center;z-index:35;">
<img src="images/senaste6_0006.png" id="senShape21" alt="" title="" style="border-width:0;width:654px;height:574px"></div>
<div id="wb_MasterPage1" style="margin:0;padding:0;position:absolute;left:0px;top:0px;width:1267px;height:795px;text-align:left;z-index:36;">
<div id="wb_Shape4" style="margin:0;padding:0;position:absolute;left:298px;top:85px;width:684px;height:710px;text-align:center;z-index:0;">
<img src="images/master_page_0004.png" id="Shape4" alt="" title="" style="border-width:0;width:684px;height:710px"></div>
<div id="wb_Shape2" style="margin:0;padding:0;position:absolute;left:300px;top:86px;width:680px;height:67px;text-align:center;z-index:1;">
<img src="images/master_page_0005.png" id="Shape2" alt="" title="" style="border-width:0;width:680px;height:67px"></div>
<img src="images/master_page_0012.png" id="Text11" alt="" border="0" style="position:absolute;left:357px;top:5px;width:568px;height:95px;z-index:2">
<div id="wb_Extension1" style="margin:0;padding:0;position:absolute;left:842px;top:16px;width:285px;height:50px;text-align:left;z-index:3;">
</div>
<div id="wb_Shape5" style="margin:0;padding:0;position:absolute;left:300px;top:752px;width:680px;height:40px;text-align:center;z-index:4;">
<img src="images/master_page_0015.png" id="Shape5" alt="" title="" style="border-width:0;width:680px;height:40px"></div>
<div id="NavigationBar1" style="position:absolute;left:336px;top:86px;width:612px;height:59px;z-index:5">
<ul class="navbar">
<li><a href="./index.php"><img alt="" src="images/master_page_0024_over.png"><span><img alt="" src="images/master_page_0024.png"></span></a></li>
<li><a href="./om.php"><img alt="" src="images/master_page_0025_over.png"><span><img alt="" src="images/master_page_0025.png"></span></a></li>
<li><a href="./kontakta.php"><img alt="" src="images/master_page_0026_over.png"><span><img alt="" src="images/master_page_0026.png"></span></a></li>
</ul>
</div>
<div id="wb_Shape12" style="margin:0;padding:0;position:absolute;left:987px;top:84px;width:280px;height:710px;text-align:center;z-index:6;">
<img src="images/master_page_0027.png" id="Shape12" alt="" title="" style="border-width:0;width:280px;height:710px"></div>
<div id="wb_Shape16" style="margin:0;padding:0;position:absolute;left:1002px;top:607px;width:252px;height:182px;text-align:center;z-index:7;">
<img src="images/master_page_0028.png" id="Shape16" alt="" title="" style="border-width:0;width:252px;height:182px"></div>
<div id="wb_Shape14" style="margin:0;padding:0;position:absolute;left:989px;top:86px;width:276px;height:67px;text-align:center;z-index:8;">
<img src="images/master_page_0030.png" id="Shape14" alt="" title="" style="border-width:0;width:276px;height:67px"></div>
<div id="wb_Shape13" style="margin:0;padding:0;position:absolute;left:1027px;top:86px;width:200px;height:59px;text-align:center;z-index:9;">
<img src="images/master_page_0034.png" id="Shape13" alt="" title="" style="border-width:0;width:200px;height:59px"></div>
<div id="wb_Shape17" style="margin:0;padding:0;position:absolute;left:989px;top:533px;width:276px;height:67px;text-align:center;z-index:10;">
<img src="images/master_page_0036.png" id="Shape17" alt="" title="" style="border-width:0;width:276px;height:67px"></div>
<div id="wb_Shape18" style="margin:0;padding:0;position:absolute;left:1026px;top:533px;width:200px;height:59px;text-align:center;z-index:11;">
<img src="images/master_page_0048.png" id="Shape18" alt="" title="" style="border-width:0;width:200px;height:59px"></div>
<div id="wb_Text19" style="margin:0;padding:0;position:absolute;left:1026px;top:568px;width:202px;height:16px;text-align:center;z-index:12;">
<font style="font-size:13px" color="#8B0000" face="Verdana">De senaste nyheterna</font></div>
<div id="wb_Shape11" style="margin:0;padding:0;position:absolute;left:1027px;top:461px;width:202px;height:63px;text-align:center;z-index:13;">
<a href="./anslut.php"><img src="images/master_page_0115.png" id="Shape11" alt="" title="" style="border-width:0;width:202px;height:63px"></a></div>
<div id="wb_Text13" style="margin:0;padding:0;position:absolute;left:1026px;top:121px;width:202px;height:16px;text-align:center;z-index:14;">
<font style="font-size:13px" color="#8B0000" face="Verdana">Anslut ert företag</font></div>
<div id="wb_Shape7" style="margin:0;padding:0;position:absolute;left:1002px;top:164px;width:252px;height:290px;text-align:center;z-index:15;">
<img src="images/master_page_0116.png" id="Shape7" alt="" title="" style="border-width:0;width:252px;height:290px"></div>
<div id="wb_Text14" style="margin:0;padding:0;position:absolute;left:1013px;top:181px;width:228px;height:240px;text-align:center;z-index:16;">
<font style="font-size:12px" color="#4B4B4B" face="Arial">Här kan ni som Leverantörer ansluta er för att ta emot jobb förfrågningar via Jobler.se<br>
<br>
När ni har anslutit er till Jobler.se så kommer vi att skicka ut jobb förfrågningar som vi tror passar er enligt de uppgifter ni angivit vid registrering / anslutning.<br>
<br>
I bekräftelse mailet ni får efter registrering ingår en 10 siffrig ID kod.<br>
Spara denna kod, då denna används vid kontakt med Jobler.se<br>
<br>
Tack för att ni ansluter er till<br>
 Jobler.se</font><font style="font-size:13px" color="#000000" face="Arial"> </font></div>
<div id="wb_Text4" style="margin:0;padding:0;position:absolute;left:1018px;top:622px;width:218px;height:160px;text-align:center;z-index:17;">
<font style="font-size:13px" color="#4B4B4B" face="Arial">Nu har en ny tjänsteförmedling kommit ut på nätet. <br>
<br>
</font><font style="font-size:16px" color="#4B4B4B" face="Arial"><br>
<br>
</font><font style="font-size:13px" color="#4B4B4B" face="Arial">På Jobler.se kan ni som </font><font style="font-size:12px" color="#4B4B4B" face="Arial">Privat person eller Företagare få hjälp med att hitta kompetenta och skickliga yrkesmän <br>
att urföra diverse olika uppdrag.</font></div>
<div id="wb_Shape8" style="margin:0;padding:0;position:absolute;left:14px;top:84px;width:280px;height:710px;text-align:center;z-index:18;">
<img src="images/master_page_0120.png" id="Shape8" alt="" title="" style="border-width:0;width:280px;height:710px"></div>
<div id="wb_Shape9" style="margin:0;padding:0;position:absolute;left:16px;top:86px;width:276px;height:67px;text-align:center;z-index:19;">
<img src="images/master_page_0121.png" id="Shape9" alt="" title="" style="border-width:0;width:276px;height:67px"></div>
<div id="SlideMenu1" style="position:absolute;left:31px;top:164px;width:246px;height:548px;z-index:20">
<ul>
   <li><div><a href="#">VÄLJ KATEGORI</a></div><span><!-- empty --></span>
      <ul>
         <li><a href="./bygg.php">Bygg, Anläggning</a></li>
         <li><a href="./stad.php">Städtjänster</a></li>
         <li><a href="./data.php">Data, IT, Webb</a></li>
         <li><a href="./ekonomi.php">Ekonomi, Juridik</a></li>
         <li><a href="./fastighet.php">Fastighetstjänster</a></li>
         <li><a href="./flytt.php">Flyttjänster</a></li>
         <li><a href="./hantverk.php">Hantverkare</a></li>
         <li><a href="./restaurang.php">Restaurang</a></li>
         <li><a href="./tradgard.php">Trädgårdstjänster</a></li>
         <li><a href="./vardag.php">Vardagstjänster</a></li>
         <li><a href="./kontor.php">Kontorstjänster</a></li>
         <li><a href="./maklare.php">Mäklare</a></li>
         <li><a href="./annat.php">Annat</a></li>
      </ul>
   </li>
</ul>
</div>
<div id="wb_Shape10" style="margin:0;padding:0;position:absolute;left:54px;top:86px;width:200px;height:59px;text-align:center;z-index:21;">
<img src="images/master_page_0122.png" id="Shape10" alt="" title="" style="border-width:0;width:200px;height:59px"></div>
<div id="wb_Text10" style="margin:0;padding:0;position:absolute;left:53px;top:121px;width:202px;height:16px;text-align:center;z-index:22;">
<font style="font-size:13px" color="#8B0000" face="Verdana">Välj kategori nedan</font></div>
<div id="wb_Shape15" style="margin:0;padding:0;position:absolute;left:16px;top:468px;width:276px;height:67px;text-align:center;z-index:23;">
<img src="images/master_page_0124.png" id="Shape15" alt="" title="" style="border-width:0;width:276px;height:67px"></div>
<div id="wb_Shape20" style="margin:0;padding:0;position:absolute;left:29px;top:542px;width:252px;height:244px;text-align:center;z-index:24;">
<img src="images/master_page_0125.png" id="Shape20" alt="" title="" style="border-width:0;width:252px;height:244px"></div>
<div id="wb_Text1" style="margin:0;padding:0;position:absolute;left:40px;top:549px;width:228px;height:240px;text-align:center;z-index:25;">
<font style="font-size:12px" color="#4B4B4B" face="Arial">Vill du som Privat person eller Företagare ha hjälp med att hitta yrkesmän<br>
till ett specifikt Project/Uppdrag.<br>
<br>
Det är enkelt. Lägg bara in din förfrågan här, så meddelar vi er så snart det kommit in ett svar som matchar ert ärende / förfrågan.<br>
</font><font style="font-size:12px" color="#000000" face="Arial"><br>
</font><font style="font-size:12px" color="#4B4B4B" face="Arial">Välj en passande kategori. Menyn här ovan. Fyll i era uppgifter och skicka.<br>
<br>
I bekräftelse mailet ingår en 8 siffrig <br>
ID kod, vilken ni uppger vid kontakt med Jobler.se</font></div>
<img src="images/master_page_0126.png" id="Text7" alt="" border="0" style="position:absolute;left:1057px;top:667px;width:143px;height:30px;z-index:26">
<div id="wb_Shape19" style="margin:0;padding:0;position:absolute;left:54px;top:468px;width:200px;height:59px;text-align:center;z-index:27;">
<img src="images/master_page_0127.png" id="Shape19" alt="" title="" style="border-width:0;width:200px;height:59px"></div>
<div id="wb_Text2" style="margin:0;padding:0;position:absolute;left:53px;top:503px;width:202px;height:14px;text-align:center;z-index:28;">
<font style="font-size:12px" color="#8B0000" face="Verdana">Allmän information för köpare</font></div>
</div>
<div id="wb_senShape19" style="margin:0;padding:0;position:absolute;left:315px;top:168px;width:650px;height:56px;text-align:center;z-index:37;">
<img src="images/senaste6_0010.png" id="senShape19" alt="" title="" style="border-width:0;width:650px;height:56px"></div>
<div id="wb_senShape1" style="margin:0;padding:0;position:absolute;left:356px;top:167px;width:568px;height:45px;text-align:center;z-index:38;">
<img src="images/senaste6_0011.png" id="senShape1" alt="" title="" style="border-width:0;width:568px;height:45px"></div>
<div id="wb_Shape2" style="margin:0;padding:0;position:absolute;left:578px;top:701px;width:124px;height:29px;text-align:center;z-index:39;">
<a href="./allajob.php"><img src="images/senaste6_0035.png" id="Shape2" alt="" title="" style="border-width:0;width:124px;height:29px"></a></div>
<div id="Html3" style="position:absolute;left:745px;top:706px;width:219px;height:30px;z-index:40">
<script>
<!-- Hide from old browsers

/******************************************
* Find In Page Script -- Submitted/revised by Alan Koontz (alankoontz@REMOVETHISyahoo.com)
* Visit Dynamic Drive (http://www.dynamicdrive.com/) for full source code
* This notice must stay intact for use
******************************************/

//  revised by Alan Koontz -- May 2003

var TRange = null;
var dupeRange = null;
var TestRange = null;
var win = null;


//  SELECTED BROWSER SNIFFER COMPONENTS DOCUMENTED AT
//  http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var nom = navigator.appName.toLowerCase();
var agt = navigator.userAgent.toLowerCase();
var is_major   = parseInt(navigator.appVersion);
var is_minor   = parseFloat(navigator.appVersion);
var is_ie      = (agt.indexOf("msie") != -1);
var is_ie4up   = (is_ie && (is_major >= 4));
var is_not_moz = (agt.indexOf('netscape')!=-1)
var is_nav     = (nom.indexOf('netscape')!=-1);
var is_nav4    = (is_nav && (is_major == 4));
var is_mac     = (agt.indexOf("mac")!=-1);
var is_gecko   = (agt.indexOf('gecko') != -1);
var is_opera   = (agt.indexOf("opera") != -1);


//  GECKO REVISION

var is_rev=0
if (is_gecko) {
temp = agt.split("rv:")
is_rev = parseFloat(temp[1])
}


//  USE THE FOLLOWING VARIABLE TO CONFIGURE FRAMES TO SEARCH
//  (SELF OR CHILD FRAME)

//  If you want to search another frame, change from "self" to
//  the name of the target frame:
//  e.g., var frametosearch = 'main'

//var frametosearch = 'main';
var frametosearch = self;


function search(whichform, whichframe) {

//  TEST FOR IE5 FOR MAC (NO DOCUMENTATION)

if (is_ie4up && is_mac) return;

//  TEST FOR NAV 6 (NO DOCUMENTATION)

if (is_gecko && (is_rev <1)) return;

//  TEST FOR Opera (NO DOCUMENTATION)

if (is_opera) return;

//  INITIALIZATIONS FOR FIND-IN-PAGE SEARCHES

if(whichform.findthis.value!=null && whichform.findthis.value!='') {

       str = whichform.findthis.value;
       win = whichframe;
       var frameval=false;
       if(win!=self)
{

       frameval=true;  // this will enable Nav7 to search child frame
       win = parent.frames[whichframe];

}

    
}

else return;  //  i.e., no search string was entered

var strFound;

//  NAVIGATOR 4 SPECIFIC CODE

if(is_nav4 && (is_minor < 5)) {
   
  strFound=win.find(str); // case insensitive, forward search by default

//  There are 3 arguments available:
//  searchString: type string and it's the item to be searched
//  caseSensitive: boolean -- is search case sensitive?
//  backwards: boolean --should we also search backwards?
//  strFound=win.find(str, false, false) is the explicit
//  version of the above
//  The Mac version of Nav4 has wrapAround, but
//  cannot be specified in JS

 
        }

//  NAVIGATOR 7 and Mozilla rev 1+ SPECIFIC CODE (WILL NOT WORK WITH NAVIGATOR 6)

if (is_gecko && (is_rev >= 1)) {
   
    if(frameval!=false) win.focus(); // force search in specified child frame
    strFound=win.find(str, false, false, true, false, frameval, false);

//  The following statement enables reversion of focus 
//  back to the search box after each search event 
//  allowing the user to press the ENTER key instead
//  of clicking the search button to continue search.
//  Note: tends to be buggy in Mozilla as of 1.3.1
//  (see www.mozilla.org) so is excluded from users 
//  of that browser.

    if (is_not_moz)  whichform.findthis.focus();

//  There are 7 arguments available:
//  searchString: type string and it's the item to be searched
//  caseSensitive: boolean -- is search case sensitive?
//  backwards: boolean --should we also search backwards?
//  wrapAround: boolean -- should we wrap the search?
//  wholeWord: boolean: should we search only for whole words
//  searchInFrames: boolean -- should we search in frames?
//  showDialog: boolean -- should we show the Find Dialog?


}

 if (is_ie4up) {

  // EXPLORER-SPECIFIC CODE revised 5/21/03

  if (TRange!=null) {
	  
   TestRange=win.document.body.createTextRange();
 
	  

   if (dupeRange.inRange(TestRange)) {

   TRange.collapse(false);
   strFound=TRange.findText(str);
    if (strFound) {
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;
        TRange.select();
        }


   }
   
   else {

     TRange=win.document.body.createTextRange();
     TRange.collapse(false);
     strFound=TRange.findText(str);
     if (strFound) {
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = TRange.offsetTop;
        TRange.select();
        }



   }
  }
  
   if (TRange==null || strFound==0) {
   TRange=win.document.body.createTextRange();
   dupeRange = TRange.duplicate();
   strFound=TRange.findText(str);
    if (strFound) {
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = TRange.offsetTop;
        TRange.select();
        }

   
   }

 }

  if (!strFound) alert ("String '"+str+"' not found!") // string not found

        
}
// -->
</script>

<!--  EXAMPLE FORM OF FIND-IN-PAGE SEARCH USING SUBMIT (ALLOWING 'ENTER/RETURN' KEY PRESS EVENT) -->
<form name="form1" onSubmit="search(document.form1, frametosearch); return false"><input type="text" name="findthis" size="15" title="Press 'ALT s' after clicking submit to repeatedly search page"> <input type="submit" value="Sök ID Kod" style="border:0px #000000 solid;background-color:#17AFE7;color:#FFFFFF; ACCESSKEY="s"></form>
</div>
<div id="Layer1" style="position:absolute;overflow:auto;background-color:#FDFDFD;left:316px;top:220px;width:648px;height:470px;z-index:41" title="">
<div id="Html1" style="position:absolute;left:0px;top:1px;width:631px;height:471px;z-index:29">
<style type="text/css">


body 
{    background-color: #ffffff;
   margin: 0; } div.blogitem {
   background-color: #ffffff;
     
} div.blogthumb {    margin: 0px 0px 5px 0px;    float: right;    padding: 0px 5px 0px 0px; } div.blogdate {
   font-family: Arial;    font-size: 13px;    color: #A52A00;    font-weight: bold;
   
} div.blogsubject, div.blogsubject a:link, div.blogsubject a:visited, div.blogsubject a:hover {    font-family: Arial;    font-size: 16px;    color: #FF0000;    font-weight: bold;    text-decoration: none; } div.blogcomments a:link, div.blogcomments a:visited, div.blogcomments a:hover {    font-family: Arial;    font-size: 12px;    color: #ffffff;
   background-color: #1BB7EA;
   padding: 5px 0px 5px 0px;
   margin: 5px 0px 5px 0px;
   font-weight: bold;
   cursor: hand;
   border: 1px #F4F4F4 solid;
   text-decoration: none; }

div.blogcomments a:hover {    font-family: Arial;    font-size: 12px;    color: #ffffff;
   background-color: #0A72A9;
   padding: 5px 0px 5px 0px;
   margin: 5px 0px 5px 0px;
   font-weight: bold;
   cursor: hand;
   border: 1px #F4F4F4 solid;
   text-decoration: none; } .pager {    margin: 1px 0px 1px 0px; } .page-number {    font-family: Tahoma;    font-size: 13px;    color: #FFFFFF;    background-color: #5E5EB3;    text-decoration: none;    padding: 0px 2px 0px 2px;    cursor: pointer;    border: px #93BEEB none;    margin-right: 2px; } .active  {    background-color: #93BEEB; } </style> <script type="text/javascript" src="./jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() {    $('.blog').each(function()    {       var currentPage = 0;       var numPerPage = 5;       var $blog = $(this);       var repaginate = function()       {          $blog.find('.blogitem').hide()               .slice(currentPage * numPerPage, (currentPage + 1) * numPerPage)               .show();          $blog.find('.blogdivider').hide()               .slice(currentPage * numPerPage, (currentPage + 1) * numPerPage)               .show();       };       var numRows = $blog.find('.blogitem').length;       var numPages = Math.ceil(numRows / numPerPage);       var $pager = $('<div class="pager"></div>');       for (var page = 0; page < numPages; page++)       {          $('<span class="page-number"></span>').text(page + 1)          .bind('click', {newPage: page}, function(event)          {             currentPage = event.data['newPage'];             repaginate();             $(this).addClass('active').siblings().removeClass('active');          }).appendTo($pager).addClass('clickable');       }       $pager.prependTo($blog).find('span.page-number:first').addClass('active');       repaginate();    }); }); </script>




<?php

$databasename='****'; // Name of the database
$tablename='****'; // Name of the table
$mysqladd='m'***'; // Address to the MySQL Server - Usually localhost but could be an IP address
$mysqluser='****'; // Your MySQL UserName
$mysqlpass='****'; // Your MySQL Password


//CONNECT TO MYSQL
$link=mysql_connect($mysqladd, $mysqluser, $mysqlpass) or die('Could not connect to database: ' . mysql_error());

//CONNECT TO DATABASE
mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error());








 
$query="SELECT * FROM jobadd ORDER BY Timestamp DESC LIMIT 6"; 
 
$result=mysql_query($query); 
 
$num=mysql_numrows($result); 
 
mysql_close(); 
 
 
$i=0; 
while ($i < $num) : 
?> 
 
    
    <div class="blogitem" style="display: block;"> 
    <div class="blogdivider"><img src="./images/devider.gif" width="100%" height="1px" border="0"><br></div>
    &nbsp;<font face="Arial" color="#666666" style="font-size:10px"><?php echo mysql_result($result,$i,"ID"); ?>&nbsp;|&nbsp;&nbsp;</font>&nbsp;<font face="Arial" color="#666666" style="font-size:10px">Datum: 
    <?php echo mysql_result($result,$i,"Time_of_submission"); ?></font>
    <br><div class="blogsubject">&nbsp;<?php echo mysql_result($result,$i,"Vad"); ?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo mysql_result($result,$i,"Var"); ?>
    &nbsp;&nbsp;|&nbsp;&nbsp;<?php echo mysql_result($result,$i,"Postnr"); ?>&nbsp;&nbsp;|&nbsp;&nbsp;ID Kod: <?php echo mysql_result($result,$i,"Idkod"); ?></a><br></div> 
    <font face="Arial" color="#282828" style="font-size:13px"><br> 

<div id="Svarsform1" style="position:absolute;left:230px;width:387px;height:245px;">

<form name="svarsform" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1">
<div id="wb_Text1" style="margin:0;padding:0;position:absolute;left:10px;top:2px;width:75px;height:16px;text-align:left;z-index:42;">
<font style="font-size:13px" color="#282828" face="Arial"><b>Namn:</b></font></div>
<div id="wb_Text2" style="margin:0;padding:0;position:absolute;left:10px;top:50px;width:75px;height:16px;text-align:left;z-index:43;">
<font style="font-size:13px" color="#282828" face="Arial"><b>ID Kod:</b></font></div>
<div id="wb_Text3" style="margin:0;padding:0;position:absolute;left:10px;top:98px;width:75px;height:16px;text-align:left;z-index:44;">
<font style="font-size:13px" color="#282828" face="Arial"><b>Telefon:</b></font></div>
<div id="wb_Text4" style="margin:0;padding:0;position:absolute;left:10px;top:146px;width:75px;height:16px;text-align:left;z-index:45;">
<font style="font-size:13px" color="#282828" face="Arial"><b>Epost:</b></font></div>
<div id="wb_Text5" style="margin:0;padding:0;position:absolute;left:206px;top:2px;width:95px;height:16px;text-align:left;z-index:46;">
<font style="font-size:13px" color="#282828" face="Arial"><b>Meddelande:</b></font></div>
<div id="wb_Text6" style="margin:0;padding:0;position:absolute;left:10px;top:194px;width:75px;height:16px;text-align:left;z-index:47;">
<font style="font-size:13px" color="#282828" face="Arial"><b>Företag:</b></font></div>
<input type="submit" id="Button1" name="" value="Svara på denna förfrågan" style="position:absolute;left:203px;top:216px;width:196px;height:25px;border:1px #FFFFFF solid;background-color:#12A8E5;color:#FFFFFF;font-family:Arial;font-size:13px;z-index:48">
<input type="text" id="Editbox1" class="CustomStyle" style="position:absolute;left:7px;top:19px;width:170px;height:24px;z-index:49" name="namn" value="">
<input type="text" id="Editbox2" class="CustomStyle" style="position:absolute;left:7px;top:67px;width:170px;height:24px;z-index:50" name="ID Kod" value="<?php echo mysql_result($result,$i,"Idkod"); ?>">
<input type="text" id="Editbox3" class="CustomStyle" style="position:absolute;left:7px;top:115px;width:170px;height:24px;z-index:51" name="telefon" value="">
<input type="text" id="Editbox4" class="CustomStyle" style="position:absolute;left:7px;top:163px;width:170px;height:24px;z-index:52" name="email" value="">
<input type="text" id="Editbox5" class="CustomStyle" style="position:absolute;left:7px;top:211px;width:170px;height:24px;z-index:53" name="företag" value="">
<textarea name="meddelande" id="TextArea1" class="CustomStyle" style="position:absolute;left:203px;top:19px;width:190px;height:186px;z-index:54" rows="7" cols="22"></textarea>


</form>
</div>

  
    <font face="Arial" color="#FF0000" style="font-size:12px"><b>&nbsp;Kontakt info:</b></font>
    <br> 
    <b>&nbsp;Namn: </b><?php echo mysql_result($result,$i,"Namn"); ?> 
    <br>
    <br>
    <b>&nbsp;Epost: </b><?php echo mysql_result($result,$i,"Epost"); ?>
    <br> 
    <br> 
    <b>&nbsp;Telefon: </b><?php echo mysql_result($result,$i,"Telefon"); ?> 
    <br> 
    <br> 
    <b>&nbsp;Mobil: </b><?php echo mysql_result($result,$i,"Mobil"); ?> 
    <br> 
    <br> 
    <font face="Arial" color="#FF0000" style="font-size:12px"><b>&nbsp;När skall Uppdraget börja:</b></font>
    <br> 
    &nbsp;<?php echo mysql_result($result,$i,"När"); ?> 
    <br> 
    <br> 
    <font face="Arial" color="#FF0000" style="font-size:12px"><b>&nbsp;Uppdragets uppskattade pris:</b></font>
    <br> 
    &nbsp;<?php echo mysql_result($result,$i,"Pris"); ?> kr
    <br> 
    <br> 
    <br>
    <font face="Arial" color="#FF0000" style="font-size:12px"><b>&nbsp;Beskrivning av uppdrag:</b></font>
    <br>
    &nbsp;<?php echo mysql_result($result,$i,"Beskrivning"); ?>
    <br>
    <br>
    

   
<?php 
$i++; 
endwhile; 
?> 

</body> 
</html> 
</div>
</div>
</div>
</body>

Användarvisningsbild
Marcus
Administratör
Administratör
Inlägg: 4321
Blev medlem: 2004-01-07 22:12
Ort: Skövde
Kontakt:

Re: Problem med php mail funktion

Inlägg av Marcus » 2011-11-18 00:06

1. Städa koden!
- </style><style...> på massa ställen
- ?><?php på massa ställen
- </body> på flera ställen
- Massa </div> efter </html>
2. Kodstandard följs inte, så det är svårt att följa din kod... men jag har städat lite i det styckar som tar dig till error.php.

Kod: Markera allt

<?php 
$errorpage = 'true'; 
session_start();

if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
  if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt']) { 
    unset($_POST['captcha_code'],$_SESSION['random_txt']); 
  } else {
    if ($errorpage == 'false') {
      echo '<b>Fel kod!</b><br>'; 
      echo '<a href="javascript:history.back()">Försök igen!</a>'; 
      exit; 
    }
    if ($errorpage == 'true')  { 
      header('Location: ././error.php'); 
      exit; 
    } 
  }
}  
?>
På rad 1 säger du att $errorpage = 'true' (se vad jag tycker om det nedan), vilket aldrig ändras... Så om:

Om $_SERVER['REQUEST_METHOD'] == 'POST är sant och om (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt']) är falskt så är det självklart att hamnar på "header(..)"-biten. (det är med din kod oundvikligt)

Särskilt som du inte verkar sätta vare sig $_SESSION['random_txt'] eller skicka med "captcha_code" i ditt formulär.

Btw:
Sätt hellre $errorpage = TRUE, då kan du istället göra if (!$errorpage) och sedan behöver du inte kolla upp if ($errorpage) utan klarar dig med ett "else".

Städa din kod, och posta igen...
Marcus Farrington - Administratör på phpBB Sverige
OBS! På förekommen anledning ges ingen support via PM.

Webb- & Drupalutvecklare på Webbyrå Grebban.

Skriv svar

Vilka är online

Användare som besöker denna kategori: 2 och 0 gäster