Jump to content

Problem with contact form


taliets

Recommended Posts

I have recently changed hosts for my website and have got a contact form that works perfectly on the one host but since I've copied it to the new host it doesn't seem to work. It when I submit the info in the form then it directs to the message that says I still have to fill out some more info and it should say thank you for the message, we will contact you shortly (in German).

 

They are both the exact same form because I copied the same form to the second server.

 

Here is the first link:

www.frostedberry.net/Silvia/Kontakt.php

 

Second link where the form is not working:

www.danielundsilvia.ch/Kontakt.php

 

Could someone perhaps help me with this? Thanks!

Link to comment
Share on other sites

Ok thanks guys!

 

Ok this is the code for the contact page:

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Silvia & Daniel's Wedding Website" />
<title>Silvia & Daniel</title> 
<link href="css/main.css" rel="stylesheet" type="text/css" media="all" />

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

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;
}
//-->
</script>

</head>

<body>
<!-- Site navigation menu -->
<div id="container">
<div id="content">
<div id="header">
</div>

<ul class="navbar">
  <li><a href="index.php">Home</a></li>
  <li><a href="Verlobung.php">Verlobung</a></li>
  <li><a href="Standesamtliche Hochzeit Thalwil.php">Standesamtliche Hochzeit Thalwil</a></li> 
  <li><a href="Kirchliche_Hochzeit.php">Kirchliche Hochzeit Namibia</a></li>
  <li><a href="Danube.php">Farm Danubè</a></li>
  <li><a href=" Reiseziele.php">Reiseziele Namibia</a></li>
  <li><a href="Hochzeitsfotos.php">Hochzeitsfotos</a></li>
  <li><a href="Sonstiges.php">Sonstiges</a></li> 
  <li><a href="/Silvia/Guestbook/index.php">Gaestebuch</a></li>
  <li><a href="Kontakt.php">Kontakt</a></li>
  <li id="navbar2"><img src="/Silvia/images/test_03.png" alt="Blom" width="129" height="138" border="0"/></li> 
</ul>




<!-- Main content -->
<div id="kontimg">
<h2></h2>
<form action="Kontakt2.php" class="form" method="post">
                         
		  <p><label for="Name"><strong>Name</strong></label>
		  <input name="Name" type="text" class="formfields" id="Name" size="20" /></p>     
              <p><label for="Telefon"><strong>Telefon</strong></label>
              <input name="Telefon" type="text" class="formfields" id="Telefon" size="20"/></p> 
              <p><label for="Email"><strong>E-mail</strong></label>
              <input name="Email" type="text" class="formfields" id="Email" size="20"/></p>
               <p><label for="Anfrage"><strong>Anfrage</strong></label>
       <textarea name="Anfrage" cols="20" rows="3" class="formfields" id="Anfrage"></textarea></p>
              <p><label for="senden"></label>
		  <input name="senden" type="submit" class="senden" id="senden" onClick="MM_validateForm('Name','','R','Telefon','','RisNum','Email','','RisEmail','Anfrage','','R');return document.MM_returnValue" value="Senden"></p>             

      </form>

<p class="form"><strong>Daniel Hafner</strong><br />
  Mobil: +41 794010141<br />
  Tel: +41 447203048<br /><br />
<strong>Silvia Scholz</strong><br />
  Mobil CH: +41 792343441<br />
  Mobil NAM: +26 4813517328<br />
  Tel CH: +41 447203048<br /><br />
  <a href="mailto:info@danielundsilvia.ch"><strong>info@danielundsilvia.ch</strong></a> </p>
    </div> 

</div>
</div>

</body>
</html>


 

The code of the second page that transmits the form information I'll have to send later because that is at home and I'm at work at the moment. Hope this helps so long!

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys. Sorry its taken me so long to reply to this post. I was wondering if you know where on a host admin area you can normally check to see if the register_globals are ON? I will post the code for the second contact page this weekend.

Link to comment
Share on other sites

None of this information really matters.. there's something wrong with the script. If you resolved the register_globals issue (if that is even the problem that caused the script to break...), you still have a script that wasn't properly written.

 

So whether or not this is the case, one of two things persists here. Either you have a script that relies on register_globals, and that needs to be fixed, you you have a script with some other problem and that needs to be fixed. The common denominator is that something needs to be fixed.

 

Please post the code.

 

PhREEEk

Link to comment
Share on other sites

Right here is the code for Kontakt2.php

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Silvia & Daniel's Wedding Website" />
<title>Silvia & Daniel</title> 
<link href="css/main.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body>
<!-- Site navigation menu -->
<div id="container">
<div id="content">
<div id="header">
</div>

<?php include("includes/menu.php"); ?>

<!-- Main content -->
<div class="formsubmit">
<?

if ((!$Name) || (!$Telefon) || (!$Email) || (!$Anfrage))
{
    $display .= '<p class="text" align="center">All fields are required.  Please check your information and try again.</p>';
$display .= '<p class="text" align="center"><a href=javascript:history.back()>Go back</a></p>';

}
else{

$Name = $_POST['Name'];
$Telefon = $_POST['Telefon'];
$Email = $_POST['Email'];
$Anfrage = $_POST['Anfrage'];

$fp = fopen("info.txt", "a"); 
fwrite($fp, $Name . "," .
            $Telefon . "," . 
		$Email . "," .            
		$Anfrage . "," . 
		date("M-d-Y") . "\n");
fclose($fp);

// send form results through email
$recipient = "silviascholz2006@yahoo.de";
$subject = "Feedback from website";
$forminfo = 
(
$Name . "\r" .
$Telefon . "\r" .  
$Email . "\r" .
$Anfrage . "\r\n" .
date("M-d-Y") . "\r\n\n"
);

$formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email\r\n");
$display .= '<p class="text"> Vielen Dank, dass sie sich mit uns in Verbindung gesetzt haben. Wir kontaktieren sie so schnell wie möglich. </p>
';
}

?>
<? echo $display; ?> 
</div>

</div>
</div>

</body>
</html>


Link to comment
Share on other sites

Two things:

 

1. Describe what it is not doing correctly.

 

2. Save the following code as Kontakt2.php. Fill out the form, send, post the results here.

 

PhREEEk

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Silvia & Daniel's Wedding Website" />
<title>Silvia & Daniel</title> 
<link href="css/main.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body>
<!-- Site navigation menu -->
<div id="container">
<div id="content">
<div id="header">
</div>

<?php include("includes/menu.php"); ?>

<!-- Main content -->
<div class="formsubmit">
<?php

echo "<br><pre>";
print_r($_POST);
die("</pre>");

if ((!$Name) || (!$Telefon) || (!$Email) || (!$Anfrage))
{
    $display .= '<p class="text" align="center">All fields are required.  Please check your information and try again.</p>';
$display .= '<p class="text" align="center"><a href=javascript:history.back()>Go back</a></p>';

}
else{

$Name = $_POST['Name'];
$Telefon = $_POST['Telefon'];
$Email = $_POST['Email'];
$Anfrage = $_POST['Anfrage'];

$fp = fopen("info.txt", "a"); 
fwrite($fp, $Name . "," .
            $Telefon . "," . 
		$Email . "," .            
		$Anfrage . "," . 
		date("M-d-Y") . "\n");
fclose($fp);

// send form results through email
$recipient = "silviascholz2006@yahoo.de";
$subject = "Feedback from website";
$forminfo = 
(
$Name . "\r" .
$Telefon . "\r" .  
$Email . "\r" .
$Anfrage . "\r\n" .
date("M-d-Y") . "\r\n\n"
);

$formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email\r\n");
$display .= '<p class="text"> Vielen Dank, dass sie sich mit uns in Verbindung gesetzt haben. Wir kontaktieren sie so schnell wie möglich. </p>
';
}

?>
<?php echo $display; ?> 
</div>

</div>
</div>

</body>
</html>

Link to comment
Share on other sites

1. Ok when I filled out the form it used to give me an error message on page Kontakt2.php that said go back and fill out all the details which it should never display. It should give the German message saying that the message has been sent and we'll get back to you shortly.

 

2. I have now done as you said and used your code as Kontakt2.php and this is what I got displayed on Kontakt2.php which is not right because I need the message and not the form info displayed:

 

 

 

Array

(

    [Name] => test

    [Telefon] => 333

    => test@test.com

    [Anfrage] => test

    [senden] => Senden

)

 

Link to comment
Share on other sites

Well, it seems as if your IF condition which tests for empty entries is done before those values are assigned the POSTed values. So, let's try this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Silvia & Daniel's Wedding Website" />
<title>Silvia & Daniel</title> 
<link href="css/main.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body>
<!-- Site navigation menu -->
<div id="container">
<div id="content">
<div id="header">
</div>

<?php include("includes/menu.php"); ?>

<!-- Main content -->
<div class="formsubmit">
<?php

if ( $_POST['senden'] == 'Senden' ) {
    $Name = $_POST['Name'];
    $Telefon = $_POST['Telefon'];
    $Email = $_POST['Email'];
    $Anfrage = $_POST['Anfrage'];
    if ((!$Name) || (!$Telefon) || (!$Email) || (!$Anfrage)) {
        $display .= '<p class="text" align="center">All fields are required.  Please check your information and try again.</p>';
        $display .= '<p class="text" align="center"><a href=javascript:history.back()>Go back</a></p>';
    } else {
        $fp = fopen("info.txt", "a"); 
        fwrite($fp, $Name . "," .
        $Telefon . "," . 
        $Email . "," .            
        $Anfrage . "," . 
        date("M-d-Y") . "\n");
        fclose($fp);

        // send form results through email
        $recipient = "silviascholz2006@yahoo.de";
        $subject = "Feedback from website";
        $forminfo = 
        (
        $Name . "\r" .
        $Telefon . "\r" .  
        $Email . "\r" .
        $Anfrage . "\r\n" .
        date("M-d-Y") . "\r\n\n"
        );

        $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email\r\n");
        $display .= '<p class="text"> Vielen Dank, dass sie sich mit uns in Verbindung gesetzt haben. Wir kontaktieren sie so schnell wie möglich. </p>';
    }
} else {
    // need German translation
    $disply .= '<p class="text">You cannot access this page without submitting the form.</p>';
}

?>
<?php echo $display; ?> 
</div>

</div>
</div>

</body>
</html>

 

Be aware that if this ends up working for you, this script offers no variable validation and is subject to many form-mail vulnerabilities.

 

PhREEEk

Link to comment
Share on other sites

Hi. I have now changed it to the latest code and it seems to be working but I have tested it with my email address but haven't received the email/message from the contact form yet.

 

What do you mean by: "this script offers no variable validation and is subject to many form-mail vulnerabilities" ?

 

The strange thing is my previous contact form code is working on two websites but doesn't seem to work with this one. Do you know why this could be? An example of where the old one is working is on this page:

http://www.diepoort.net/contact2.php

 

 

Link to comment
Share on other sites

What do you mean by: "this script offers no variable validation and is subject to many form-mail vulnerabilities" ?

 

See this website for clarification:

 

http://f6design.com/journal/2006/12/09/securing-php-contact-forms/

 

Hi. I have now changed it to the latest code and it seems to be working but I have tested it with my email address but haven't received the email/message from the contact form yet.

 

The strange thing is my previous contact form code is working on two websites but doesn't seem to work with this one. Do you know why this could be? An example of where the old one is working is on this page:

http://www.diepoort.net/contact2.php

 

I have no idea... I would start a new thread to get other's input. I don't have a lot of patience helping people trouble shoot PHP mail() problems (just being honest there...). I try to stick to what I enjoy the most, and that's actual code.

 

PhREEEk

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.