Please help with form email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bradw
Forum Newbie
Posts: 2
Joined: Tue Nov 08, 2005 1:27 pm

Please help with form email

Post 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!
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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']
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
bradw
Forum Newbie
Posts: 2
Joined: Tue Nov 08, 2005 1:27 pm

Post 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!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
Post Reply