Avatar billede fowler21 Nybegynder
09. august 2005 - 11:10 Der er 4 kommentarer og
1 løsning

Problemer med at include mailform script

Jeg har et mailform script, som jeg vil have included i mit design.
I min content box, har jeg følgende kode

<?if(!empty($_GET["page"])) {
include($_GET["page"]);
} else {
include("main.php");
}?>

Hvor den henter main.php som standard.
Herefter hedder mine links f.eks :
index.php?page=webdesign.php

I mailformens tilfælde hedder den mailform.php
Den bliver hentet rigtig nok frem, men når man har indtastet sine data og trykker send, kommer der ingenting frem i min content box.
Hvis man kører mailform.php for sig selv, kommer den rigtig nok frem til teksten, hvor der står at mailen er sendt.

Mailform.php ser således ud :
<!-- Copyright © 2002 Kali (http://www.xentrik.net) -->

<html>
<head>
<title>Kali's PHP Contact Form</title>

<?php
// COPYRIGHT/LIABILITY NOTICE
// Copyright © 2002 Kali (http://www.xentrik.net)
// Last modified 04/05/2004

// Kali's Contact Form may be used and modified free of charge as long as this
// copyright notice and the comments above remain intact. By using this code
// you agree to indemnify Kali from any liability that might arise from its use.

// Selling the code for this program without prior written consent is not permitted.
// Permission must be obtained before redistributing this software. In all cases the
// copyright and header information must remain intact.

// MODIFY THE FOLLOWING SECTION

// your name
$recipientname = "Mitnavn";

// your email
$recipientemail = "Min@Email.dk";

// subject of the email sent to you
$subject = "Online-Form Response for $recipientname";

// send an autoresponse to the user?
$autoresponse = "yes";

// subject of autoresponse
$autosubject = "Thank you for your mail!";

// autoresponse message
$automessage = "This is an auto response to let you know that we've successfully received your email sent through our email form. Thanks! We'll get back to you shortly.";

// thankyou displayed after the user clicks "submit"
$thanks = "Thank you for contacting us.<br>We will get back to you as soon as possible.<br>";

// END OF NECESSARY MODIFICATIONS

?>

<style type="text/css"><!--
td,body,input,textarea {
        font-size:12px;
        font-family:Verdana,Arial,Helvetica,sans-serif;
        color:#000000}
--></style>
</head>
<body>

<table width="100%" height="100%"><tr>
<td valign="top"><font face="Verdana,Arial,Helvetica" size="2">

<?php
if($_POST['submitform']) {

$Name = $HTTP_POST_VARS['Name'];
$Email = $HTTP_POST_VARS['Email'];
$Comments = $HTTP_POST_VARS['Comments'];
$require = $HTTP_POST_VARS['require'];

// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]<br>";
}
}

// check email address
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Invalid email address<br>";}

// display errors
if($error) {
?>

<b>Fejl</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">try again</a>


<?php
}
else
{

$browser = $_SERVER["HTTP_USER_AGENT"];
$ip = $_SERVER["REMOTE_ADDR"];

// format message
$message = "Online-Form Response for $recipientname:

Name: $Name
Email: $Email

Comments: $Comments

-----------------------------

Browser: $browser
User IP: $ip";

// send mail and print success message
mail($recipientemail,"$subject","$message","From: $Name <$Email>");

if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}

echo "$thanks";
}
}
else {
?>

<form name="contactform" action="<?php echo $PHP_SELF; ?>" method="post">
<input type="hidden" name="require" value="Name,Email,Comments">
<table><tr>
<td colspan="2" align="center"><b><font size="2" face="Verdana,Arial,Helvetica">Kontakt</font></b>  <p></td>
</tr><tr>
<td valign="top" align="right">Name:</td>
<td valign="top"><input name="Name" size="25"></td>
</tr><tr>
<td valign="top" align="right">E-mail:</td>
<td valign="top"><input name="Email" size="25"></td>
</tr><tr>
<td valign="top" align="right">Comments:</td>
<td valign="top"><textarea name="Comments" rows="5" cols="35"></textarea></td>
</tr><tr>
<td colspan="2" align="center"><input type="submit" value="Send" name="submitform">
<input type="reset" value="Nulstil" name="reset"></td>
</tr></table>
<br>

</form>
<?php } ?>
</font></td>
</tr></table>

</body>
</html>

på forhånd tak
Avatar billede delphinarious Nybegynder
09. august 2005 - 15:10 #1
Det er formentligt actionen i formularen, den er gal med. Den sender nok ikke querystringen "mailform.php" med, vel?
Avatar billede delphinarious Nybegynder
09. august 2005 - 15:12 #2
... altså: Gør det til:

<form name="contactform" action="<?php echo $PHP_SELF."?page=mailform.php"; ?>" method="post">
Avatar billede fowler21 Nybegynder
09. august 2005 - 15:46 #3
Det virker delphinarious. Tak. Smid et svar og pointene er dine :)
Avatar billede delphinarious Nybegynder
09. august 2005 - 15:48 #4
Det var godt. :-)
Avatar billede delphinarious Nybegynder
09. august 2005 - 15:55 #5
Tak for points. ;-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester