943,708 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3173
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Dec 23rd, 2008
0

Re: Email Form - Checkbox help

i took off the echo though and replaced that with the code you gave me. What i have on my website is basically the layout and the content. The layout is in a header.php file, and the content are in the other .php's every page such as proposal .php includes the header(layout). Is there any other way i can do this then? Here is a better explanation of what i said.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
<!--
.style2 {font-size: 14px; }
-->
</style>

</head>

<body>


<?
include("../header.php"); //This includes the layout 


$name= $_POST['name'];
$from = $_POST["email"];
$to = "blah@blah.com";
$subject = "Proposal Request";
$message = "Company Name: " . $_POST["companyname"] . "\n";
$message .= "Telephone Number:" . $_POST["telephonenumber"] . "\n";
$message .= "Email Address:" . $_POST["email"] . "\n";
$message .= "Company Name:" . $_POST["companyname"] . "\n";
$message .= "Company Address:" . $_POST["location"] . "\n";
$message .= "City:" . $_POST["city"] . "\n";
$message .= "State:" . $_POST["state"] . "\n";

//Checkboxes
//Service Needed
$service = $_POST['service'];
 if(is_array($service))
{
    $message .= "Type of Service needed:" .implode(", ",$service). "\n";
}

//Best Time to Contact
$time = $_POST['time'];
 if(is_array($time))
{
    $message .= "Best Time to Contact:"  .implode(", ",$time). "\n";
}




//Contact Preference
$cpref = $_POST['cpref'];
 if(is_array($cpref))
{
    $message .= "Contact by Email/Phone:"  .implode(", ",$cpref). "\n";
}



if($sent){
	$headers = 'From: ' . $name . ' <' . $from . '>' . "\r\n" .
		'Reply-To: ' . $from . "\r\n" .
		'X-Mailer: PHP/' . phpversion();
	
	mail($to, $subject, $message, $headers);
	//echo "The Email Has Been Sent";
	header("location:thankyou.php"); //that gives me the error
        

	

}
?>

Is there anyway i can do this?
Last edited by jhonnyboy; Dec 23rd, 2008 at 5:52 pm.
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008
Dec 23rd, 2008
0

Re: Email Form - Checkbox help

Yes, delete everything before the <? delimiter and use the script as a cgi. Since you are doing a redirect, you don't need to send any content to the browser. Just the header.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 23rd, 2008
0

Re: Email Form - Checkbox help

you mean delete all the html headers and stuff? and change the extension from header.php to header.cgi?
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008
Dec 23rd, 2008
0

Re: Email Form - Checkbox help

If still u are getting error try this code in place of header("location:thankyou.php");

PHP Syntax (Toggle Plain Text)
  1.  
  2. echo "<script language='JavaScript'>
  3. location.href='thankyou.php';
  4. </script>";
Reputation Points: 10
Solved Threads: 5
Light Poster
manish.s is offline Offline
29 posts
since Dec 2008
Dec 23rd, 2008
0

Re: Email Form - Checkbox help

Quote ...
you mean delete all the html headers and stuff? and change the extension from header.php to header.cgi?
No don't change the .php extension. Here's how I would do it:
php Syntax (Toggle Plain Text)
  1. <?php
  2. $name= $_POST['name'];
  3. $from = $_POST["email"];
  4. $to = "blah@blah.com";
  5. $subject = "Proposal Request";
  6. $message = "Company Name: " . $_POST["companyname"] . "\n";
  7. $message .= "Telephone Number:" . $_POST["telephonenumber"] . "\n";
  8. $message .= "Email Address:" . $_POST["email"] . "\n";
  9. $message .= "Company Name:" . $_POST["companyname"] . "\n";
  10. $message .= "Company Address:" . $_POST["location"] . "\n";
  11. $message .= "City:" . $_POST["city"] . "\n";
  12. $message .= "State:" . $_POST["state"] . "\n";
  13.  
  14. //Checkboxes
  15. //Service Needed
  16. $service = $_POST['service'];
  17. if(is_array($service))
  18. {
  19. $message .= "Type of Service needed:" .implode(", ",$service). "\n";
  20. }
  21.  
  22. //Best Time to Contact
  23. $time = $_POST['time'];
  24. if(is_array($time))
  25. {
  26. $message .= "Best Time to Contact:" .implode(", ",$time). "\n";
  27. }
  28. //Contact Preference
  29. $cpref = $_POST['cpref'];
  30. if(is_array($cpref))
  31. {
  32. $message .= "Contact by Email/Phone:" .implode(", ",$cpref). "\n";
  33. }
  34. if($sent){
  35. $headers = 'From: ' . $name . ' <' . $from . '>' . "\r\n" .
  36. 'Reply-To: ' . $from . "\r\n" .
  37. 'X-Mailer: PHP/' . phpversion();
  38.  
  39. mail($to, $subject, $message, $headers);
  40. header("location:thankyou.php");
  41. exit;
  42. }
  43. ?>
  44. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  45. <html xmlns="http://www.w3.org/1999/xhtml">
  46. <head>
  47. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  48. <title></title>
  49. <style type="text/css">
  50. <!--
  51. .style2 {font-size: 14px; }
  52. -->
  53. </style>
  54.  
  55. </head>
  56.  
  57. <body>
  58.  
  59.  
  60. <?php
  61. include("../header.php"); //This includes the layout
  62. ?>
Notice how most of the server side processing is done before the doctype. Also, the header is sent prior to any html output.
Last edited by buddylee17; Dec 23rd, 2008 at 10:20 pm.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php mysql drop down list
Next Thread in PHP Forum Timeline: AOL block emails created from my server





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC