The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V  1 2 >  
Reply to this topicStart new topic
> help needed with contact form, contact form sending blank messages
jakes
post Mar 18 2015, 07:08 PM
Post #1


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



hi everyone

i am having problems with a contact form.i seem to be getting a email from the contact form but in the email its blank so i cant see what has been typed in the form and i get this message in the email unknown sender and these fields are blank Name:
Email:
message:


i think there is a problem with the contact form code or something as the only thing is wrong is that the message is blank appreciate if anyone can help.fidn below contact form code



<head>

<title>music</title>
<!-- indie -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> contact form</title>
<style type="text/css">
body {
background-color: #069;
}
body,td,th {
font-size: large;
font-weight: bold;
color: #000;
}
</style>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
</script>
</head>

<body>
<p><img src="cooltext1931496504.png" width="966" height="86"></p>
<p>&nbsp;</p>
<p><a href="index.html"><img src="Back button.png" width="129" height="40"></a></p>
<p>&nbsp; </p>
<form action="action: mailto:myemail" method="get" enctype="enctype:text/plain" name="form1" id="form1">
<p>&nbsp;</p>
<p>
<label for="name3">name</label>
<input name="name" type="text" id="name4" value="" size="50">
<label for="jjjj"></label>
</p>
<p>&nbsp;</p>
<p>
<label for="Email">Email</label>
<input name="Email" type="text" id="Email" size="50" maxlength="30" />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>
<label for="Message">Message</label>
<textarea name="Message" cols="60" rows="10" id="Message"></textarea>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="contact form1.php"><img src="submit button.png" width="140" height="40"></a></p>
<p>&nbsp;</p>
</form>
<p><a href="button.png"></a><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('submit','','cooltext192 6436576.png',1)"></a></p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 18 2015, 08:29 PM
Post #2


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



QUOTE(jakes @ Mar 19 2015, 01:08 AM) *

<form action="action: mailto:myemail" method="get" enctype="enctype:text/plain" name="form1" id="form1">

The above ACTION value is incorrect. Furthermore "mailto:" forms only work if the user's computer has an email program installed (and sometimes not even then), they don't work with webmail. See also http://htmlhelp.com/faq/html/forms.html#mailto-form

As a sidenote the HTML contains many errors. Insert a Doctype like

CODE
<!doctype html>

at the very beginning and use http://validator.w3.org/ to find the errors.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Mar 18 2015, 08:43 PM
Post #3


Programming Fanatic
********

Group: Members
Posts: 1,680
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



This type of contact form 'action="mailto:myemail" ' will only work if the user has some type of e-mail client installed. It will not work for users with web-based e-mail.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 18 2015, 09:37 PM
Post #4


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



QUOTE(Christian J @ Mar 19 2015, 02:29 AM) *

The above ACTION value is incorrect.

To elaborate, it should look something like this:

CODE
<form action="mailto:foo@bar.com">

But again, mailto forms are fragile at best.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 20 2015, 01:39 PM
Post #5


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



i have now chnaged it to action="action:contactform1.php"method="get"enctype="enctype:text/plain" name="form1" id="form1">

as contactform1 is the name of the php file that process the form.still getting blank emails with no messages.just don`t know which part of the code is stopping me from viewing messages from contact form
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Mar 20 2015, 02:28 PM
Post #6


WDG Member
********

Group: Root Admin
Posts: 8,317
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE
action="action:contactform1.php"
This should be just:

action="contactform1.php"
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 20 2015, 02:48 PM
Post #7


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



Also, can you post the PHP code from contactform1.php?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 21 2015, 03:34 PM
Post #8


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



thanks to everyone taking time out to help find php code below

<?php





/* Email Variables */
$emailSubject = 'music';
$webMaster = 'my email';



/* Data Variables */
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];



$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
message: $message <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=contact form page url i put here">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">your message has been successfully sent we will contact you shortly</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 21 2015, 03:35 PM
Post #9


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



after filling out contact form all i get is blank messages
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 21 2015, 05:23 PM
Post #10


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



CODE
/* Data Variables */
$email = $_POST['email'];
$message = $_POST['message'];

The above POST variables are in lower case, but the corresponding HTML form fields are capitalized:

CODE
<input name="Email"
<textarea name="Message"

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 21 2015, 05:50 PM
Post #11


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



do u think thats the reason why i get no text in the emails

Name:
Email:
message:

thats what comes in the email but the text is missing
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 21 2015, 06:53 PM
Post #12


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



QUOTE(jakes @ Mar 21 2015, 11:50 PM) *

do u think thats the reason why i get no text in the emails

It's one reason. Now I also noticed that the form lacks a submit button, e.g.

CODE
<input type="submit" value="Post message">

In contrast, the following is just a link to the PHP script:

CODE
<a href="contact form1.php"><img src="submit button.png" width="140" height="40"></a>

it will not submit the form, but makes the PHP script run anyway and send an email without form data.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 21 2015, 06:57 PM
Post #13


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



ok i see
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 22 2015, 07:12 AM
Post #14


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



whats the best and easiest way to link a submit button to the php script not sure how as from what u have said its the button
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 22 2015, 08:35 AM
Post #15


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



Just put the submit button in the form, and the browser takes care of the rest.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 22 2015, 10:55 PM
Post #16


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



i put the button but i still get the same thing no text in the email,maybe its a problem on the web server side
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 23 2015, 08:45 AM
Post #17


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



Found another error in the HTML form. This:

CODE
method="get"

must be changed to

CODE
method="post"

Something like this:

CODE
<form action="contactform1.php" method="post">

(I think you can remove the ENCTYPE attribute also.)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 23 2015, 09:09 PM
Post #18


.
********

Group: WDG Moderators
Posts: 8,254
Joined: 10-August 06
Member No.: 7



QUOTE(Christian J @ Mar 23 2015, 02:45 PM) *

CODE
<form action="contactform1.php" method="post">

(I think you can remove the ENCTYPE attribute also.)

Indeed it seems enctype="text/plain" messes up form submissions: http://stackoverflow.com/questions/7628249...-not-compatible
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 27 2015, 06:32 AM
Post #19


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



CODE
head>

<meta name="description"content="" />
<meta name="keywords"content="" />
<meta name="author"content="">
<meta name="robots"content="index, follow">
<meta name="revisit-after"content="3 days">
<title></title>
<!-- music -->
<meta http-equiv="Content-Type"content="text/html;charset=utf-8" />
<title></title>
<style type="text/css">
body {
background-color: #069;
}
body,td,th {
font-size: large;
font-weight: bold;
color: #000;
}
</style>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
</script>
</head>

<body>
<p><img src="cooltext1931496504.png"width="966"height="86"></p>
<p> </p>
<p><a href="index.html"><img src="Back button.png"width="139"height="40"></a></p>
<p>  </p>
<form action="contact form1.php" method="post">
<p> </p>
<p>
<label for="name3">name</label>
<input name="name" type="text" id="name4"value=""size="50" />
<label for="jjjj"></label>
</p>
<p> </p>
<p>
<label for="Email">Email</label>
<input name="Email"type="text"id="Email"size="50"maxlength="30" />
</p>
<p> </p>
<p> </p>
<p>
<label for="Message">Message</label>
<textarea name="Message" cols="60"rows="10"id="Message"></textarea>
</p>
<p> </p>
<p> </p>
<p><input name="submit"type="submit"id="button"value="Send"></p>
</a></p>
<p> </p>
</form>
<p><a href="button.png"></a><a href="#"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage('submit','','cooltext1926436576.png',1)"></a></p>
<p> </p>
<p>  </p>
</body>
</html>[code][/code]




<?php



/* Email Variables */
$emailSubject = 'music!';
$webMaster = 'testserve@hotmail.com';



/* data variables */
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];



$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
message: $message <br>
EOD;
$headers ="From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh"content="3;URL=domain">
<style type="text/css">
<!--
body {
background-color: #444;
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">your message has been successfully sent we will contact you shortly</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>

This post has been edited by jakes: Mar 27 2015, 06:33 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
jakes
post Mar 27 2015, 06:33 AM
Post #20


Newbie
*

Group: Members
Posts: 10
Joined: 18-March 15
Member No.: 22,395



i added the changes still the same problem
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 10th December 2019 - 05:03 PM