Email Form - Checkbox help

Reply

Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: Email Form - Checkbox help

 
0
  #11
Dec 23rd, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: Email Form - Checkbox help

 
0
  #12
Dec 23rd, 2008
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.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: Email Form - Checkbox help

 
0
  #13
Dec 23rd, 2008
you mean delete all the html headers and stuff? and change the extension from header.php to header.cgi?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: manish.s is an unknown quantity at this point 
Solved Threads: 1
manish.s manish.s is offline Offline
Newbie Poster

Re: Email Form - Checkbox help

 
0
  #14
Dec 23rd, 2008
If still u are getting error try this code in place of header("location:thankyou.php");

  1.  
  2. echo "<script language='JavaScript'>
  3. location.href='thankyou.php';
  4. </script>";
-- Manish Singh
manish.s@neuralit.com
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: Email Form - Checkbox help

 
0
  #15
Dec 23rd, 2008
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:
  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.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC