...

View Full Version : e-mailing form



Netjunky
09-13-2009, 05:30 AM
hello

i am trying to make a form to be e-mailed to me but have a problem.

i used two different tutorials that i made with dreamweaver and am trying to test it on xampp the first one "untitled-1.php comes up on foxfire with no errors but still cant send it to my email here is the code...


<!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>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>

<?php
if (isset($_POST['Submit'])) {
$to = "myemailaddress";
$subject = "Registration Form";
$body = "hi \n
name: ".$_POST['name']." \n
identification: ".$_POST['identification']." \n
contact: ".$_POST['contact']." \n
age: ".$_POST['age']." \n
education: ".$_POST['education']." \n
computer: ".$_POST['computer']." \n
goal: ".$_POST['goal']." \n

\n
thank you
";
}
mail($to, $subject, $body)


?>

<form id="form1" name="form1" method="post" action="Untitled-1.php">
<table width="100%" border="0" cellpadding="6">
<tr>
<td colspan="2"><div align="center" class="style1">
<div align="center"><strong>form title</strong></div>
</div></td>
</tr>
<tr>
<td width="50%"><div align="right">
<label for="name"><strong>Name</strong></label>
</div></td>
<td width="50%"><div align="left">
<input name="name" type="text" id="name" size="100" maxlength="80" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="identification"><strong>Identification Shown</strong></label>
</div></td>
<td><div align="left">
<input name="identification" type="text" id="identification" size="100" maxlength="300" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="contact"><strong>Contact Information</strong></label>
</div></td>
<td><div align="left">
<textarea name="contact" cols="100" id="contact"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Optional Information</strong></div></td>
<td><div align="left">
<p>&nbsp;</p>
<p><strong>Age Range</strong></p>
<p>
<label>
<input type="radio" name="age" value="radio" id="age_0" />
<strong>16-22</strong></label>
<strong><br />
<label>
<input type="radio" name="age" value="radio" id="age_1" />
23-29</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_2" />
30-36</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_3" />
37-43</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_4" />
44-50</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_5" />
50+</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="education"><strong>Level of Education</strong></label>
</div></td>
<td><div align="left">
<input name="education" type="text" id="education" size="100" maxlength="400" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Computer Experience</strong></div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="computer" value="radio" id="computer_0" />
<strong>Experienced</strong></label>
<strong><br />
<label>
<input type="radio" name="computer" value="radio" id="computer_1" />
Average</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_2" />
Beginner</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_3" />
Poor</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="goal"><strong>goal goal </strong></label>
</div></td>
<td><div align="left">
<p>
<textarea name="goal" cols="100" id="goal"></textarea>
</p>
<p><strong>(example: learning to construct a resume, preparing for a job interview, learning basic computer skills, preparing to write a General Educational Development(GED) exam)</strong></p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Clear Form" />
</div></td>
<td><div align="left">
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</body>
</html>

</body>
</html>


the second one untitled-2.php has this error: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\xampp\htdocs\Untitled-2.php on line 36

and here is this code...(line 36 in bold)


<?php
/* subject and email variables */


$emailSubject = 'Form Submitted';
$webMaster = 'myemailaddress';

/* Gathering Data Variables */

$nameField = $_POST['name'];
$identificationField = $_POST['identification'];
$contactField = $_POST['contact'];
$ageField = $_POST['age'];
$educationField = $_POST['education'];
$computerField = $_POST['computer'];
$goalField = $_POST['goal'];


$body = <<<EOD
<br><hr><br>
Name: $name <br>
Identification Shown: $identification <br>
Contact Information: $contact <br>
Optional Information Age: $age <br>
Level of Education: $deucation <br>
What is your main goal while learning at the new ONE Change CALNET Access Center: $goal <br>
EOD;



$headers .= "Content-type: text/html\r\n";
$success - mail($webmaster, $emailSubject, $body, $headers

/* Results rendered as HTML*/

$theresults = <<<EOD
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>

<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "theResults";

?>

<form id="form1" name="form1" method="post" action="Untitled-2.php">
<table width="100%" border="0" cellpadding="6">
<tr>
<td colspan="2"><div align="center" class="style1">
<div align="center"><strong>form title</strong></div>
</div></td>
</tr>
<tr>
<td width="50%"><div align="right">
<label for="name"><strong>Name</strong></label>
</div></td>
<td width="50%"><div align="left">
<input name="name" type="text" id="name" size="100" maxlength="80" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="identification"><strong>Identification Shown</strong></label>
</div></td>
<td><div align="left">
<input name="identification" type="text" id="identification" size="100" maxlength="300" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="contact"><strong>Contact Information</strong></label>
</div></td>
<td><div align="left">
<textarea name="contact" cols="100" id="contact"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Optional Information</strong></div></td>
<td><div align="left">
<p>&nbsp;</p>
<p><strong>Age Range</strong></p>
<p>
<label>
<input type="radio" name="age" value="radio" id="age_0" />
<strong>16-22</strong></label>
<strong><br />
<label>
<input type="radio" name="age" value="radio" id="age_1" />
23-29</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_2" />
30-36</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_3" />
37-43</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_4" />
44-50</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_5" />
50+</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="education"><strong>Level of Education</strong></label>
</div></td>
<td><div align="left">
<input name="education" type="text" id="education" size="100" maxlength="400" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Computer Experience</strong></div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="computer" value="radio" id="computer_0" />
<strong>Experienced</strong></label>
<strong><br />
<label>
<input type="radio" name="computer" value="radio" id="computer_1" />
Average</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_2" />
Beginner</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_3" />
Poor</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="goal"><strong>goal goal </strong></label>
</div></td>
<td><div align="left">
<p>
<textarea name="goal" cols="100" id="goal"></textarea>
</p>
<p><strong>(example: learning to construct a resume, preparing for a job interview, learning basic computer skills, preparing to write a General Educational Development(GED) exam)</strong></p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Clear Form" />
</div></td>
<td><div align="left">
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</body>
</html>

</body>
</html>


i think the untitled-1 is ok but just cant get it to send is there someting i should set on xampp or is it the code????

abduraooft
09-13-2009, 06:32 AM
$headers .= "Content-type: text/html\r\n";
$success - mail($webmaster, $emailSubject, $body, $headers

/* Results rendered as HTML*/ Did you mean

$headers .= "Content-type: text/html\r\n";
$success = mail($webmaster, $emailSubject, $body, $headers);

/* Results rendered as HTML*/ there?

Netjunky
09-13-2009, 08:46 AM
that fixed that up - look like = on youtube tutorials but still cant receive the e-mail.

im not sure about the "webmaster" that was just in the tutorial too.

Is it something different when sending to a hotmail.com address

abduraooft
09-13-2009, 09:00 AM
$webMaster = 'myemailaddress';


Is it something different when sending to a hotmail.com address Yes, replace that part with the email id to which you need to send the message.

Netjunky
09-13-2009, 09:23 AM
yeah i did just put that there so my address isnt on the forum

i used a my hotmail.com, gmail.com, and yahoo.com too and never received anything not even in the spam.

can it be something in the xampp???

abduraooft
09-13-2009, 09:34 AM
can it be something in the xampp??? If you are testing from a Windows machine, you need to have an SMTP server running in it.

Netjunky
09-13-2009, 06:32 PM
yeah i woke up thinking the same thing but how do i set up xampp for that??

the SMTP service says DEACTIVATED

clunk.werclick
09-13-2009, 07:59 PM
Be aware that the anti-spam policy of hotmail/gmail/others does not necessarily mean 'spam' will ever get as far as a spam directory. If the sending IP does not have a valid DNS ptr record or the IP is blacklisted for being in a dialup/dsl range(such as a home server running on dsl/cable connection) chances are you'll never see the mail. You may be lucky and get greylisted for a few minutes, but you'll probably get dropped, so pay attention to the SMTP service logs.

If you want to test it against my anti-spam feel free to fire it at cf13092009@wibblywobblyteapot.co.uk. If I reply, I got it. If not, it got blocked. I'm happy to look in the logs and tell you why.

Hope that's helpful or useful to you in some way. If you are after a good free SMTP/MAIL server for windows Mailenable standard is pretty good, easy to install and free.

Netjunky
09-13-2009, 10:52 PM
cf13092009@wibblywobblyteapot.co.uk[/email]. If I reply, I got it. If not, it got blocked. I'm happy to look in the logs and tell you why.

sent it to that email address
[QUOTE=
If you are after a good free SMTP/MAIL server for windows Mailenable standard is pretty good, easy to install and free.[/QUOTE]

got Mailenable standard but when i got to the 3 box it said "World Wide Web Publishing Service has not been installed on this computer". there's always something :mad:
where or how do i install that little gem..


and found out that its not able to be installed on my system xp home

Netjunky
09-14-2009, 06:35 AM
ok i borrowed windows server 2003 and am putting it on my other pc is there anything special i should do so both pcs can use it ?


there both connected to my router.

clunk.werclick
09-14-2009, 08:10 AM
Yep, XP home has IIS missing AFAIR, but let's not jump too far ahead here. If all you are trying to do is send mail from PHP and you are running on windows you should be able to make use of your ISP's SMTP server. This will probably require authentication, and a quick google has thrown up this;

http://email.about.com/od/emailprogrammingtips/qt/et073006.htm

What you have done is added a remote SMTP server on your network in the shape of that W23K box, so the link will equally apply to that server or your ISP's mail server)

Personally, unless you are sending 'bulk' mail, Your ISP mail server is probably going to be the better option. I imagine it is set up properly, with correct DNS entries, host name and does not have a blacklisted IP. Square to that, your W23K box is probably going to be on your DSL/Cable/dynamic IP address without correct entries in DNS. This most likely means any email coming from it will be dropped by anti-spam measures. Usually It won't make it as far as a 'spam' mailbox - it will be dropped during the SMTP conversation and sit in the outbound queue.

I hope this helps :-)

Netjunky
09-14-2009, 08:22 PM
i tried all the examples in that site

http://email.about.com/od/emailprogr...t/et073006.htm


none of them worked

clunk.werclick
09-14-2009, 08:27 PM
Do you have any messages in the apache error logs or mail server logs?

Netjunky
09-18-2009, 12:41 AM
Do you have any messages in the apache error logs or mail server logs?

Mon Sep 14 16:30:34 2009] [error] [client 127.0.0.1] script 'C:/xampp/xampp/htdocs/untitled-1.php' not found or unable to stat

thats the only log in C:\xampp\xampp\apache\logs

i have even installed windows server 2003 and followed these tutorial

http://www.visualwin.com/PHP/
http://www.simongibson.com/intranet/php2003/


still cant do nothing with it but the tutorials dont tell you how to open the .php or where to put it.

but i did this one first i dont know if it would make any difference

http://win2k3.msfn.org/

why cant they just make things easy??:confused:

Netjunky
09-22-2009, 07:06 AM
ok

i got a domain name and have a host server

i can send emails to my domain mail address and redirect it to my hotmail address but still cant send the form to my email the host server is hosthelper

if anyone knows what is wrong with this code please respond





here is the new code




<?php
/* subject and email variables */


$emailSubject = 'Form Submitted';
$webMaster = 'my emil address.co.cc';

/* Gathering Data Variables */

$nameField = $_POST['name'];
$identificationField = $_POST['identification'];
$contactField = $_POST['contact'];
$ageField = $_POST['age'];
$educationField = $_POST['education'];
$computerField = $_POST['computer'];
$goalField = $_POST['goal'];


$body = <<<EOD
<br><hr><br>
Name: $name <br>
Identification Shown: $identification <br>
Contact Information: $contact <br>
Optional Information Age: $age <br>
Level of Education: $deucation <br>
What is your main goal : $goal <br>
EOD;



$headers .= "Content-type: text/html\r\n";
$success = mail($webmaster, $emailSubject, $body, $headers);

/* Results rendered as HTML*/

$theresults = <<<EOD
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>

<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "theResults";

?>

<form id="form1" name="form1" method="post" action="file:///C|/Documents and Settings/All Users/Documents/Untitled-2.php">
<table width="100%" border="0" cellpadding="6">
<tr>
<td colspan="2"><div align="center" class="style1">
<div align="center"><strong>form title</strong></div>
</div></td>
</tr>
<tr>
<td width="50%"><div align="right">
<label for="name"><strong>Name</strong></label>
</div></td>
<td width="50%"><div align="left">
<input name="name" type="text" id="name" size="100" maxlength="80" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="identification"><strong>Identification Shown</strong></label>
</div></td>
<td><div align="left">
<input name="identification" type="text" id="identification" size="100" maxlength="300" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="contact"><strong>Contact Information</strong></label>
</div></td>
<td><div align="left">
<textarea name="contact" cols="100" id="contact"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Optional Information</strong></div></td>
<td><div align="left">
<p>&nbsp;</p>
<p><strong>Age Range</strong></p>
<p>
<label>
<input type="radio" name="age" value="radio" id="age_0" />
<strong>16-22</strong></label>
<strong><br />
<label>
<input type="radio" name="age" value="radio" id="age_1" />
23-29</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_2" />
30-36</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_3" />
37-43</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_4" />
44-50</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_5" />
50+</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="education"><strong>Level of Education</strong></label>
</div></td>
<td><div align="left">
<input name="education" type="text" id="education" size="100" maxlength="400" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Computer Experience</strong></div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="computer" value="radio" id="computer_0" />
<strong>Experienced</strong></label>
<strong><br />
<label>
<input type="radio" name="computer" value="radio" id="computer_1" />
Average</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_2" />
Beginner</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_3" />
Poor</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="goal"><strong> What is your main goal </strong></label>
</div></td>
<td><div align="left">
<p>&nbsp; </p>
<p>
<textarea name="goal" cols="100" id="goal"></textarea>
</p>
<p><strong>(example: learning to construct a resume, preparing for a job interview, learning basic computer skills, preparing to write a General Educational Development(GED) exam)</strong></p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Clear Form" />
</div></td>
<td><div align="left">
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</body>
</html>

</body>
</html>

clunk.werclick
09-22-2009, 08:33 AM
First of all you are calling a file to handle your form:
"C|/Documents and Settings/All Users/Documents/Untitled-2.php"
Personally I would not do this (it may or may not work), I would call the file by URL.

Second, you had some typo's in your file ThisVariable is *not* the same as thisvariable.

Third, your Heredoc (EOD) was referencing the wrong variable names and in the wrong way.

Forth a typo in the echoing of results to the screen.

Other issues, fixing these would still leave a form firing a blank email each time it loaded freshly as there was no logic to check if this was a process or display form run. I've added a very crude if form_submitted trap to stop this.

To fix for you;
You will need to to code the results from your Radio buttons. At the moment you will just get 'RADIO' as a result. You will need to change your email address in the script.
There is obviously room for serious enhancment and tidying up of the script, but this is tested and working on my Apache this morning:
(Upload to /htdocs/ (or whatever your web root it) and call it test.php)



<?php
/* Gathering Data Variables */
$submit_button_pressed = $_POST['submit'];
$nameField = $_POST['name'];
$identificationField = $_POST['identification'];
$contactField = $_POST['contact'];
$ageField = $_POST['age'];
$educationField = $_POST['education'];
$computerField = $_POST['computer'];
$goalField = $_POST['goal'];

if ($submit_button_pressed) {
$body = <<<EOD
<br><hr><br>
Name: {$nameField} <br>
Identification Shown: {$identificationField} <br>
Contact Information: {$contactField} <br>
Optional Information Age: {$ageField} <br>
Level of Education: {$educationField} <br>
Computer Field: {$computerField} <br>
What is your main goal : {$goalField} <br>
EOD;
/* subject and email variables */
$emailsubject = 'Form Submitted';
$webmaster = 'INSERT@YOUREMAIL.ADDRESS';
$headers = 'From: Webbot <noreply@example.com>' . "\r\n" .
'Reply-To: noreply@example.com' . "\r\n" .
'Content-Type: text/html; charset=ISO-8859-1';
$success = mail($webmaster, $emailsubject, $body, $headers);
/* Results rendered as HTML*/
$theresults = <<<EOD
<html>
<head>
<title>Email Test Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
//echo "theResults";
echo $theresults;
exit();
}
?>
<html>
<head>
<title>Email Test Form</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="test.php">
<table width="100%" border="0" cellpadding="6">
<tr>
<td colspan="2"><div align="center" class="style1">
<div align="center"><strong>form title</strong></div>
</div></td>
</tr>
<tr>
<td width="50%"><div align="right">
<label for="name"><strong>Name</strong></label>
</div></td>
<td width="50%"><div align="left">
<input name="name" type="text" id="name" size="100" maxlength="80" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="identification"><strong>Identification Shown</strong></label>
</div></td>
<td><div align="left">
<input name="identification" type="text" id="identification" size="100" maxlength="300" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="contact"><strong>Contact Information</strong></label>
</div></td>
<td><div align="left">
<textarea name="contact" cols="100" id="contact"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Optional Information</strong></div></td>
<td><div align="left">
<p>&nbsp;</p>
<p><strong>Age Range</strong></p>
<p>
<label>
<input type="radio" name="age" value="radio" id="age_0" />
<strong>16-22</strong></label>
<strong><br />
<label>
<input type="radio" name="age" value="radio" id="age_1" />
23-29</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_2" />
30-36</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_3" />
37-43</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_4" />
44-50</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_5" />
50+</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="education"><strong>Level of Education</strong></label>
</div></td>
<td><div align="left">
<input name="education" type="text" id="education" size="100" maxlength="400" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Computer Experience</strong></div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="computer" value="radio" id="computer_0" />
<strong>Experienced</strong></label>
<strong><br />
<label>
<input type="radio" name="computer" value="radio" id="computer_1" />
Average</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_2" />
Beginner</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_3" />
Poor</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="goal"><strong> What is your main goal </strong></label>
</div></td>
<td><div align="left">
<p>&nbsp; </p>
<p>
<textarea name="goal" cols="100" id="goal"></textarea>
</p>
<p><strong>(example: learning to construct a resume, preparing for a job interview, learning basic computer skills, preparing to write a General Educational Development(GED) exam)</strong></p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Clear Form" />
</div></td>
<td><div align="left">
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</body>
</html>

</body>
</html>


No doubt better PHP coders than me will be able to improve this no end.

Netjunky
09-25-2009, 02:52 AM
First of all you are calling a file to handle your form:
"C|/Documents and Settings/All Users/Documents/Untitled-2.php"
Personally I would not do this (it may or may not work), I would call the file by URL.

Second, you had some typo's in your file ThisVariable is *not* the same as thisvariable.

Third, your Heredoc (EOD) was referencing the wrong variable names and in the wrong way.

Forth a typo in the echoing of results to the screen.

Other issues, fixing these would still leave a form firing a blank email each time it loaded freshly as there was no logic to check if this was a process or display form run. I've added a very crude if form_submitted trap to stop this.

To fix for you;
You will need to to code the results from your Radio buttons. At the moment you will just get 'RADIO' as a result. You will need to change your email address in the script.
There is obviously room for serious enhancment and tidying up of the script, but this is tested and working on my Apache this morning:
(Upload to /htdocs/ (or whatever your web root it) and call it test.php)



<?php
/* Gathering Data Variables */
$submit_button_pressed = $_POST['submit'];
$nameField = $_POST['name'];
$identificationField = $_POST['identification'];
$contactField = $_POST['contact'];
$ageField = $_POST['age'];
$educationField = $_POST['education'];
$computerField = $_POST['computer'];
$goalField = $_POST['goal'];

if ($submit_button_pressed) {
$body = <<<EOD
<br><hr><br>
Name: {$nameField} <br>
Identification Shown: {$identificationField} <br>
Contact Information: {$contactField} <br>
Optional Information Age: {$ageField} <br>
Level of Education: {$educationField} <br>
Computer Field: {$computerField} <br>
What is your main goal : {$goalField} <br>
EOD;
/* subject and email variables */
$emailsubject = 'Form Submitted';
$webmaster = 'INSERT@YOUREMAIL.ADDRESS';
$headers = 'From: Webbot <noreply@example.com>' . "\r\n" .
'Reply-To: noreply@example.com' . "\r\n" .
'Content-Type: text/html; charset=ISO-8859-1';
$success = mail($webmaster, $emailsubject, $body, $headers);
/* Results rendered as HTML*/
$theresults = <<<EOD
<html>
<head>
<title>Email Test Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
//echo "theResults";
echo $theresults;
exit();
}
?>
<html>
<head>
<title>Email Test Form</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="test.php">
<table width="100%" border="0" cellpadding="6">
<tr>
<td colspan="2"><div align="center" class="style1">
<div align="center"><strong>form title</strong></div>
</div></td>
</tr>
<tr>
<td width="50%"><div align="right">
<label for="name"><strong>Name</strong></label>
</div></td>
<td width="50%"><div align="left">
<input name="name" type="text" id="name" size="100" maxlength="80" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="identification"><strong>Identification Shown</strong></label>
</div></td>
<td><div align="left">
<input name="identification" type="text" id="identification" size="100" maxlength="300" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="contact"><strong>Contact Information</strong></label>
</div></td>
<td><div align="left">
<textarea name="contact" cols="100" id="contact"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Optional Information</strong></div></td>
<td><div align="left">
<p>&nbsp;</p>
<p><strong>Age Range</strong></p>
<p>
<label>
<input type="radio" name="age" value="radio" id="age_0" />
<strong>16-22</strong></label>
<strong><br />
<label>
<input type="radio" name="age" value="radio" id="age_1" />
23-29</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_2" />
30-36</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_3" />
37-43</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_4" />
44-50</label>
<br />
<label>
<input type="radio" name="age" value="radio" id="age_5" />
50+</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="education"><strong>Level of Education</strong></label>
</div></td>
<td><div align="left">
<input name="education" type="text" id="education" size="100" maxlength="400" />
</div></td>
</tr>
<tr>
<td><div align="right"><strong>Computer Experience</strong></div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="computer" value="radio" id="computer_0" />
<strong>Experienced</strong></label>
<strong><br />
<label>
<input type="radio" name="computer" value="radio" id="computer_1" />
Average</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_2" />
Beginner</label>
<br />
<label>
<input type="radio" name="computer" value="radio" id="computer_3" />
Poor</label>
</strong><br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="goal"><strong> What is your main goal </strong></label>
</div></td>
<td><div align="left">
<p>&nbsp; </p>
<p>
<textarea name="goal" cols="100" id="goal"></textarea>
</p>
<p><strong>(example: learning to construct a resume, preparing for a job interview, learning basic computer skills, preparing to write a General Educational Development(GED) exam)</strong></p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Clear Form" />
</div></td>
<td><div align="left">
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" />
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</body>
</html>

</body>
</html>


No doubt better PHP coders than me will be able to improve this no end.

404 - NOT FOUND - The server can not find the requested page:


yep that did it i had to change the indexhtml and the form.html

Netjunky
09-25-2009, 02:56 AM
i do get the page up every now and then but when i check my mail i get this

A message that you sent contained no recipient addresses, and therefore no
delivery could be attempted.

------ This is a copy of your message, including all the headers. ------

To:
Subject: Form Submitted
Content-type: text/html
Message-Id: <E1MqzWA-0001by-BA@gamma.freecp.net>
From: netjunky@gamma.freecp.net
Date: Thu, 24 Sep 2009 18:22:38 -0700


<br><hr><br>
Name: <br>
Identification Shown: <br>
Contact Information: <br>
Optional Information Age: <br>
Level of Education: <br>
What is your main goal : <br>


A message that you sent contained no recipient addresses, and therefore no
delivery could be attempted.

i though i was the recipient

clunk.werclick
09-25-2009, 07:50 AM
You have tried the reworked script above?

Check the lines:


$webmaster = 'INSERT@YOUREMAIL.ADDRESS';
.....
$success = mail($webmaster, $emailsubject, $body, $headers);

Put in the correct email address.

How are you testing this? With a hosting account or on a local machine?

Netjunky
09-25-2009, 10:14 PM
yeah i seen that and an other place i needed to put my address also fixed the radio buttons


thanks all



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum