Page 1 of 1

Need PHP help

Posted: Thu May 17, 2007 7:59 pm
by milan1612
Hi,

I'm trying to implement a contact form into my website.
The following code only sends a empty mail :shock:
I'm new to PHP. Could somebody please correct it? :oops:

An extract from the code...

Code: Select all

<?php

  $mail_to="milan1612@gmx.de";

  $from_name=$_POST['fromname'];
  $from_mail=strtolower($_POST['frommail']);
  $mail_subject=$_POST['mailsubject'];
  $mail_text=$_POST['mailtext'];

  trim($from_name);
  trim($from_mail);
  trim($mail_subject);
  trim($mail_text);

  if(strlen($mail_text)>1000)
  {
    $mail_text=substr($mail_text,0,1000)."... (has been shorted!)";
  }
  
  $from_name=str_replace(chr(34),"''",$from_name);
  $mail_subject=str_replace(chr(34),"''",$mail_subject);
?>

<p>Questions, suggestion or question? Or do you have a wish what I could develop 
next? Feel free to contact me...</p>
<p>&nbsp;</p>
<table style="width: 100%; height: 254px">
	<tr>
		<td style="width: 73px; height: 20px"><b>Name</b>:</td>
		<td style="height: 18px">
		<form method="post" style="height: 18px" class="style2">
			<input name="fromname" value="<?php echo $from_name; ?>" type="text" style="width: 200px; height: auto" /></form>
		</td>
	</tr>
	<tr>
		<td style="width: 73px; height: 20px"><b>Email</b>:</td>
		<td style="height: 18px">
		<form method="post" style="height: 18px" class="style2">
			<input name="frommail"  value="<?php echo $from_mail; ?>" type="text" style="width: 200px; height: auto" class="style2" /></form>
		</td>
	</tr>
	<tr>
		<td style="width: 73px; height: 20px"><b>Subject</b>:</td>
		<td style="height: 18px">
		<form method="post" class="style2" style="height: 18px">
			<input name="mailsubject" type="text" value="<?php echo $mail_subject; ?>" style="width: 200px; height: auto" /></form>
		</td>
	</tr>
	<tr>
		<td style="width: 73px; height: 71px"><b>Message</b></td>
		<td style="height: 71px">
		<form method="post" style="width: 436px; height: 127px" class="style2">
			<textarea name="mailtext" style="width: 435px; height: 126px"><?php echo $mail_text; ?></textarea></form>
		</td>
	</tr>
	<tr>
		<td style="width: 73px; height: 22px"></td>
		<td style="height: 22px">
		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" class="style4">
			<input name="submit" type="submit" value="Send" style="width: 120px; height: 23px" /></form>
		</td>
	</tr>
</table>

<?php
  $header="From: $from_name <$from_mail>\n";
  $header.="Reply-To: $from_mail\n";
  $header.="X-Mailer: PHP-FormMailer (www.gaijin.at)\n";
  $header.="Content-Type: text/plain";
  

  $mail_text = utf8_decode($mail_text);
  $mail_to = utf8_decode($mail_to);
  $header = utf8_decode($header);

  
  @mail($mail_to,$mail_subject,$mail_text,$header)
?>
Thanks in advance...

PS: I know that's no PHP forum :)