Welcome!

Join our community of MMORPG enthusiasts and private server developers! By registering, you'll gain access to in-depth discussions on source codes, binaries, and the latest developments in MMORPG server files. Collaborate with like-minded individuals, explore tutorials, and share insights on building and optimizing private servers. Join us today and unlock the full potential of MMORPG server development!

Join Today!

Mail form problem

Joined
Apr 29, 2005
Messages
6,404
Reaction score
130
Location
The Netherlands
Well, I have this E-mail form

Contact.php:
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body background="images/index_06.gif">
<font face="Arial, Helvetica, sans-serif"><font size="1"><font color="#FFFFFF">
<form method="post" action="sendeail.php">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
Attention:<br />
<select name="attn" size="1">
<option value=" Sales n Billing ">Graphical requests(wallpapers, signatures etc.) </option>
<option value=" General Support ">Template request (Please specify if you want it coded or not. </option>
<option value=" Technical Support ">Forum skin request (Please specify for which board.) </option>
<option value=" Webmaster ">Other (Please specify.) </option>
</select>
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
</form>
</font></font></font>
</body>
</html>

Sendeail.php:
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body background="images/index_06.gif">
<font face="Arial, Helvetica, sans-serif"><font size="1"><font color="#FFFFFF">
<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("pieter@pie-designs.net", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="index.html"> Back to home </a>
</p>
</font></font></font>
</body>
</html>

But the weird thing is, that when someone clicks "send mail" The e-mail gets sent but when it arrives, it looks like this:

Attention:

Message:

From: ()

Additional Info : IP =

Browser Info:

Referral :

As you can see, nothing is filled in while the fields were filled in. Anyone got any clue what's wrong?
 
The problem is at your sendeail.php, if you want to use variables, you need to define them before using it. Also, check the $message I modified from line 36-42.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body bgcolor="#000000">
<font face="Arial, Helvetica, sans-serif"><font size="1"><font color="#FFFFFF">
<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php
/* This is the part you forgets to put */
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
/* End of defining variables */
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $_POST['attn'];
$subject = $attn;

$notes = stripcslashes($notes);

$message = " ".$todayis." [EST] \n
Attention: ".$attn." \n
Message: ".$notes." \n
From: ".$visitor." (".$visitormail.")\n
Additional Info : IP = ".$ip." \n
Browser Info: ".$httpagent." \n
Referral : ".$httpref." \n
";

$from = "From: ".$visitormail."\r\n";


mail("hackerkts@gmail.com", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis; ?>
<br />
Thank You : <?php echo $visitor; ?> ( <?php echo $visitormail; ?> )
<br />

Attention: <?php echo $attn; ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip; ?>

<br /><br />
<a href="index.html"> Back to home </a>
</p>
</font></font></font>
</body>
</html>

Hope that helps.
 
Back