Solved

_POST not posting to my variables

Posted on 2010-09-01
2
259 Views
Last Modified: 2012-05-10
Guys,

I don't understand whats wrong here, this is almost a complete copy from an original working form i had before and this thing is shooting me emails with my message but not including the values for my fields. For example it's giving me Name: .... Email: ..... Comments: .....

This is my HTML Form, and everything works fine:

 
<form id="contacts" method="post" enctype="multipart/form-data" action="include/inc_sendmail.php">

                            <input tabindex="1" type="text" id="visitor" name="name" value="Name" onfocus="if (this.value=='Name') this.value='';" onblur="if (this.value=='') this.value='Name';" class="required name" minlength="5" />
                          <br />
                                
                                <input tabindex="2" type="text" id="visitormail" name="email" value="E-mail" onfocus="if (this.value=='E-mail') this.value='';" onblur="if (this.value=='') this.value='E-mail';" class="required email" />
                                <br />

                                
                                <textarea tabindex="3" id="notes" name="comment" cols="30" rows="3" onfocus="if (this.value=='Message') this.value='';" onblur="if (this.value=='') this.value='Message';" class="required" minlength="10">Message</textarea>
                                <br />

                            	<input class="button" name="Send" value="Send e-mail" type="submit" />
                            	
                        	</fieldset>
                        </form>

Open in new window



Here is my "working" php file:


 
<?php

ini_set("sendmail_from", "xxxxx@gmail.com");


$name = $_POST['visitor'];
$email = $_POST['visitormail'];
$comment = $_POST['notes'];
$from = $email;

$message = "Name: $name \n\n Email: $email \n\n Comments: $comment\n\n";



if (!@mail("xxxxx@gmail.com","Portfolio Contact", $message,"From: $from\nContent-Type: text/html; charset=iso-8859-1")) {
	echo "<script language='javascript'>alert('There have been some problems sending the email');</script>"
	."<meta http-equiv='refresh' content='0;url=../index.html'>";
	
} else {
	echo "<script language='javascript'>alert('Thank you for contacting me');</script>"
	."<meta http-equiv='refresh' content='0;url=../index.html'>";
}
?>

Open in new window



Anyone see anything obvious i'm missing here?
0
Comment
Question by:Arka3L
2 Comments
 
LVL 2

Accepted Solution

by:
IngCharlie earned 500 total points
Comment Utility
Name and Id must have the same value



<form id="contacts" method="post" enctype="multipart/form-data" action="include/inc_sendmail.php">

                            <input tabindex="1" type="text" id="visitor" name="visitor" value="Name" onfocus="if (this.value=='Name') this.value='';" onblur="if (this.value=='') this.value='Name';" class="required name" minlength="5" />
                          <br />
                               
                                <input tabindex="2" type="text" id="visitormail" name="visitormail" value="E-mail" onfocus="if (this.value=='E-mail') this.value='';" onblur="if (this.value=='') this.value='E-mail';" class="required email" />
                                <br />

                               
                                <textarea tabindex="3" id="notes" name="notes" cols="30" rows="3" onfocus="if (this.value=='Message') this.value='';" onblur="if (this.value=='') this.value='Message';" class="required" minlength="10">Message</textarea>
                                <br />

                                  <input class="button" name="Send" value="Send e-mail" type="submit" />
                                  
                              </fieldset>
                        </form>
0
 
LVL 1

Author Closing Comment

by:Arka3L
Comment Utility
Interesting, i had no idea! That fixed it.

thanks again for the prompt answer :D
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now