Page 1 of 1

Please help with form email

Posted: Tue Nov 08, 2005 1:32 pm
by bradw
Hello,
I took over this site which has several forms which are processed by their relative .php scripts.
So far none are functioning. Is there a problem with this code?:

note - i have changed the real email addresses for this post

Code: Select all

<?php
	$myname = "Promise Magazine";
	$myemail = "emailaddress@domain.com";

	$contactname = "Promise Magazine Hostmaster";
	$contactemail = "emailaddress@domain.com";

	$cBody = $cBody . "Name: " . $name . "<br>     ";
	$cBody = $cBody . "Email: " . $email  . "<br>     ";
	$cBody = $cBody . "City, State: " . $city . "<br>     ";
	$cBody = $cBody . "Zip or Country Code: " . $zip . "<br>     ";
	$cBody = $cBody . "Phone 1: " . $phone1 . "<br>     ";
	$cBody = $cBody . "Comments: " . $comments . "<br>     ";
	$subject = "Promise Magazine - Comments from " . $name;

	$headers  = "MIME-Version: 1.0\r\n";
	$headers = $headers . "Content-type: text/html; charset=iso-8859-1\r\n";
	$headers = $headers . "From: ".$myname." <".$myemail.">\r\n";
	$headers = $headers . "To: ".$contactname." <".$contactemail.">\r\n";
	$headers = $headers . "Reply-To: ".$myname." <".$myreplyemail.">\r\n";
	$headers = $headers . "X-Priority: 1\r\n";
	$headers = $headers . "X-MSMail-Priority: High\r\n";
	$headers = $headers . "X-Mailer: Email Server";

	mail($contactemail, $subject, $cBody, $headers);?>
Many thanks in advance!

Posted: Tue Nov 08, 2005 1:37 pm
by s.dot
perhaps you do not have register_globals on. I don't see where $name and the other variables are coming from.. perhaps they should be $_POST['name']

Posted: Tue Nov 08, 2005 1:52 pm
by bradw
perhaps this will help,
here is the HTML form:

The PHP code above is in the file 'comments.php' which is referred to by the HTML here. Once again, I am just taking over this site and did not write the code, and am not experienced with PHP.

Code: Select all

<form name="feedback" method="post" action="comments.php" onSubmit="MM_validateForm('name','','R','email','','NisEmail','phone1','','NisNum','comments','','R');return document.MM_returnValue">
    <tr> 
      <td rowspan="8"><div style="width: 20;"></div></td>
      <td colspan="2"> <div align="center" style="margin-top: 20;"><img src="images/common/com_opinion.gif"></div></td>
      <td rowspan="8"><div style="width: 20;"></div></td>
    </tr>
    <tr> 
      <td> Name (Last, First)</td>
      <td><input type="text" size="17" name="name" maxlength="100"></td>
    </tr>
    <tr> 
      <td>E-mail</td>
      <td><input type="text" size="17" name="email"></td>
    </tr>
    <tr> 
      <td>City, State</td>
      <td><input type="text" size="17" name="city"></td>
    </tr>
    <tr> 
      <td>Zip or Country</td>
      <td><input type="text" size="17" name="zip" maxlength="30"></td>
    </tr>
    <tr> 
      <td>Contact Phone</td>
      <td><input type="text" size="17" name="phone1" maxlength="30"></td>
    </tr>
    <tr> 
      <td colspan="2"><img src="images/common/com_comment.gif"><br>
	  <textarea name="comments" rows="4" cols="27" wrap="virtual"></textarea></td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center" style="margin-bottom: 20;"> 
          <input type="image" value="Submit" name="I1" src="images/common/submit.gif" onClick="MM_validateForm('email','','NisEmail','phone1','','NisNum','comments','','R');return document.MM_returnValue" width="64" height="21">
        </div></td>
    </tr>
  </form>
Thanks!

Posted: Tue Nov 08, 2005 2:00 pm
by Burrito
What scrotaye suggested is feasibly correct.

are you receiving any errors?

you might try putting this at the top of your php page if you're not:

Code: Select all

error_reporting(E_ALL);
it will display any errors that the script encounters while trying to execute.

I would tend to lead toward what scrotaye suggested in that you probably don't have register globals on.

try replacing the page vars with the variables from the $_POST[] array.