?
Solved

why do i not receive any form data when email is submitted?

Posted on 2008-10-22
11
Medium Priority
?
178 Views
Last Modified: 2010-04-16
When i tested my form, i got the email but none of the data entered into any of the fields showed up when i received the email

below is the form
www.celebrityspeakerslv.com/contact.html
0
Comment
Question by:Observer11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22782441
First thing you need to do is change the name of your file from contact.html to contact.php

It contains hidden fields that rely on PHP. If the problem persists, then you will need to post the code for your sendeail.php file.
0
 

Author Comment

by:Observer11
ID: 22782547
oh ok. thanks.
so i changed it to php and replaced the html file, but when i filled out the php file it gave me the same results..

So what exactly would i need to do in terms of posting the code for my snedeail.php file?
0
 
LVL 82

Expert Comment

by:hielo
ID: 22782641
you need to download a copy of sendeail.php to YOUR machine, open it via notepad, then copy and paste the code on this post/thread, preferably by clicking on Attach Code Snippet and pasting your code there.

Before you post your code make sure you remove any sensitive information including real email addresses.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:nick_bal
ID: 22782660
In my example i will only use name and email as form elements. You can get the point and add all the others. I have a page called contact.php which sends the data to itself (your can change that and send it to another). I hope it helps..
<? 
if($_POST['action']==1){
 
if(!$_POST['fullname'] or !$_POST['email']){$msg = "Fields marked with * are required";$error=1;}
 
if(!$error){
  $subject = "subject subject";
  $message = $_POST['fullname']."\n";
  $message .= $_POST['email'];
		
  $headers  = 'MIME-Version: 1.0' . "\r\n";
  $headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n";
  $headers .= 'From: <'.$_POST['email'].'>';
  
  $to = "youremail@youremail.com";
		
  if (mail($to, $subject, $message, $headers)){
     $msg = "Thank you for your interest. We will contact you as soon as possible.";
  }
  else{
     $msg="A problem has occured. Please try again.";
     $error=1;
  }
		
	
}
 
}
?>
 
<? if($msg){echo $msg."<br><br><br>";}?>
 
<form name="form1" method="post" action="contact.php">
   <input type="hidden" name="action" value="1">
   Name: <input type="text" name="fullname" value="<? echo $_POST['fullname'];?>"> *<br>
   Email: <input type="text" name="email" value="<? echo $_POST['email'];?>"> *<br>
   <input type="submit" value="SEND">
</form>

Open in new window

0
 

Author Comment

by:Observer11
ID: 22782696

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title>
</head>
<body>
 
<!-- Required: YOUR email ($myemail). Optional: Enter CC email address ($ccx) 
Required: Add the link for the 'next page' (at the bottom) --> 
 
<?php
 
$myemail = "myemail@mixvegasmedia.com";
$ccx = "myemail@mixvegasmedia.com"; 
 
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;
 
$todayis = date("l, F j, Y, g:i a") ;
 
$attn = $attn . "(" . $ccopy . ")" ; 
$subject = $attn; 
 
$notes = stripcslashes($notes); 
 
$message = " $todayis [EST] \n
Attention: $attn \n
Name of Group: $group \n
Your Title: $title \n
Your Address: $address \n
Phone Number: $phone \n
Date and Time of Event: $date \n
Number of Expected Attendees: $attendees \n
Place of Event: $place \n
Theme of Event: $theme \n
Budget: $budget \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
 
$from = "From: $visitormail\r\n";
 
if (($ccopy == "ccyes") && ($visitormail != "")) 
mail($visitormail, $subject, $message, $from);
 
if ($myemail != "") 
mail($myemail, $subject, $message, $from);
 
if ($ccx != "") 
mail($ccx, $subject, $message, $from);
 
?>
 
<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
<br />
 
Attention: <?php echo $attn ?>
<br /> 
Message:<br /> 
<?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
<br />
<?php echo $ip ?> 
 
<br /><br />
<a href="index.htm"> Next Page </a> 
</p> 
 
</body>
</html>

Open in new window

0
 
LVL 1

Expert Comment

by:nick_bal
ID: 22782734
It seems that you dont use $_POST['formelement'] but just the string.
eg: Your Address: $address

If the form method in the previous page is POST you should use:
Your Address: $_POST['address']

Unless the method is GET (not good at all) so you should use
Your Address: $_GET['address']
0
 
LVL 82

Expert Comment

by:hielo
ID: 22782865
try chaning this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
 
to this:
<?php
extract($_POST);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

Open in new window

0
 
LVL 1

Expert Comment

by:nick_bal
ID: 22782882
If there is a collision, extract($_POST) overwrites the existing variable. So i find it better to use $_POST['submittedformelement'] because sometimes i may use a variable with the same name.
0
 

Author Comment

by:Observer11
ID: 22789485
ok i think i got a bit clearer, but im a bit of a begginer at this. so im just not sure what exactly to replace with what.

Could you perhaps take my last code snippet above and replace what needs to be replaced and provide the whole page code in another snippet.. this way i can see exactly what was changed.

thanks
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22789593

<?php
extract($_POST);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Sendemail Script</title>
</head>
<body>
 
<!-- Required: YOUR email ($myemail). Optional: Enter CC email address ($ccx) 
Required: Add the link for the 'next page' (at the bottom) --> 
 
<?php
 
$myemail = "myemail@mixvegasmedia.com";
$ccx = "myemail@mixvegasmedia.com"; 
 
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;
 
$todayis = date("l, F j, Y, g:i a") ;
 
$attn = $attn . "(" . $ccopy . ")" ; 
$subject = $attn; 
 
$notes = stripcslashes($notes); 
 
$message = " $todayis [EST] \n
Attention: $attn \n
Name of Group: $group \n
Your Title: $title \n
Your Address: $address \n
Phone Number: $phone \n
Date and Time of Event: $date \n
Number of Expected Attendees: $attendees \n
Place of Event: $place \n
Theme of Event: $theme \n
Budget: $budget \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
 
$from = "From: $visitormail\r\n";
 
if (($ccopy == "ccyes") && ($visitormail != "")) 
mail($visitormail, $subject, $message, $from);
 
if ($myemail != "") 
mail($myemail, $subject, $message, $from);
 
if ($ccx != "") 
mail($ccx, $subject, $message, $from);
 
?>
 
<p align="center">
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
<br />
 
Attention: <?php echo $attn ?>
<br /> 
Message:<br /> 
<?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
<br />
<?php echo $ip ?> 
 
<br /><br />
<a href="index.htm"> Next Page </a> 
</p> 
 
</body>
</html>

Open in new window

0
 

Author Comment

by:Observer11
ID: 22817412
yay! thank you!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question