Log in

View Full Version : PHP Email form problems...



Harlem Of Nem
08-20-2007, 12:15 PM
I have been trying for a few weeks now to get this code to work but I have now just given up...

Please can someone help me to get the following code to work?

The form...


<!--CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="http://harlem9191.joolo.com/Clan%20News.css" type="text/css" rel="stylesheet" />
<form action="http://nemesisclan.myfreewebs.net/sendeail.php" method="post">
<!-- DO NOT change ANY of the php sections --><!--p
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
--><input type="hidden" name="ip" value="&lt;?php echo $ipi ?&gt;" /> <input type="hidden" name="httpref" value="&lt;?php echo $httprefi ?&gt;" /> <input type="hidden" name="httpagent" value="&lt;?php echo $httpagenti ?&gt;" /><font face="calligraph421 BT" color="#ffffff" size="2"><label style="FLOAT: left; WIDTH: 140px" for="name">Runescape Username:<input class="codebuttons" id="name" style="WIDTH: 200px" maxlength="12" name="name" /> <label style="FLOAT: left; WIDTH: 140px" for="cb">Combat Level:</label><input class="codebuttons" id="cb" style="FLOAT: left; WIDTH: 25px" maxlength="3" name="cb" /> <label style="FLOAT: left; WIDTH: 140px" for="al">Attack Level:</label><input class="codebuttons" id="al" style="FLOAT: left; WIDTH: 18px" maxlength="2" name="al" /> <label style="FLOAT: left; WIDTH: 140px" for="sl">Strength Level:</label><input class="codebuttons" id="sl" style="FLOAT: left; WIDTH: 18px" maxlength="2" name="sl" /> <label style="FLOAT: left; WIDTH: 140px" for="dl">Defence Level:</label><input class="codebuttons" id="dl" style="FLOAT: left; WIDTH: 18px" maxlength="2" name="dl" /> <label style="FLOAT: left; WIDTH: 140px" for="rl">Range Level:</label><input class="codebuttons" id="rl" style="FLOAT: left; WIDTH: 18px" maxlength="2" name="rl" /> <label style="FLOAT: left; WIDTH: 140px" for=ml">Mage Level:</label><input class="codebuttons" id="ml" style="FLOAT: left; WIDTH: 18px" maxlength="2" name="ml" />
<div style="CLEAR: left; HEIGHT: 20px"></div>
<label style="DISPLAY: block; MARGIN-BOTTOM: 5px" for="why">Why do you think you should join Nemesis?</label><input class="codebuttons" id="why" style="WIDTH: 300px; HEIGHT: 100px" maxlength="1000" name="why" /> <label style="DISPLAY: block; MARGIN-BOTTOM: 5px" for="other">Other:</label><input class="codebuttons" id="other" style="WIDTH: 300px; HEIGHT: 100px" maxlength="1000" name="other" /> <label style="FLOAT: left; WIDTH: 140px">Member or Clan Friend?:</label><span style="DISPLAY: block; WIDTH: 400px" name="mocf"><input id="J1radioOption" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px; BACKGROUND-COLOR: transparent" type="radio" name="Member" value="1" /><label for="J1radioOption">Member:</label><input id="J2radioOption" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px; BACKGROUND-COLOR: transparent" type="radio" name="Clanfriend" value="2" /><label for="J2radioOption">Clan Friend:</label></span> <label style="FLOAT: left; WIDTH: 140px">Finish:</label><span style="DISPLAY: block; WIDTH: 400px" name="finish"><input id="K1checkboxOption" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; VERTICAL-ALIGN: middle; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px; BACKGROUND-COLOR: transparent" type="checkbox" name="finish" value="1" /><label for="K1checkboxOption">Are you happy with your application?</label></span></label></font>
<div style="CLEAR: left; HEIGHT: 20px"></div>
<br />
<center><input class="codebuttons" type="submit" value="Submit Registration" /></center>
</form>

Code to send email...


<!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>

<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$name = $_POST['name'];
$cb = $_POST['cb'];
$al = $_POST['al'];
$dl = $_POST['dl'];
$sl = $_POST['sl'];
$rl = $_POST['rl'];
$ml = $_POST['ml'];
$other = $_POST['other'];
$why = $_POST['why'];
$mocf = $_POST['mocf'];
$finish = $_POST['finish'];

if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Nemesis Applicant...";

$notes = stripcslashes($notes);

$message = "Submitted on: $todayis [EST] \n
From: $name \n\n
Combat level: $cb \n
Attack Level: $al \n
Defence Level: $dl \n
Strength Level: $sl \n
Range Level: $rl \n
Mage Level: $ml \n
Why should you join nemesis?: $why \n
Other: $other \n
Member or Clan Friend: $mocf \n\n

Additional Info: IP = $ip \n
Browser Info: $httpagent \n
";

$from = "From: $name\r\n";


mail("harlem111@hotmail.co.uk", $subject, $message, $from);

?>

<p align="center">
Thank You : <?php echo $name ?>
<br />
This form was submitted on: <?php echo $todayis ?>
<br />
Your IP address is:<?php echo $ip ?>

<br /><br />
<a href="http://s10.invisionfree.com/nemesisrsclan/index.php?act=Reg&CODE=00">Next Step</a>
</p>

</body>
</html>

boogyman
08-20-2007, 12:47 PM
have you narrowed down your problem at all?

what are you having trouble with?
besides the obvious of getting it to work

Harlem Of Nem
08-20-2007, 01:27 PM
Oh sorry I forgot... I am having trouble with the actual form being sent to my email...
I use hotmail and the hosting provider I use is myfreewebs.net

I have just mentioned the above because looking through the internet people have had problems with there hosting provider or email provider (thought it might have helped you a bit)

boogyman
08-20-2007, 01:54 PM
does myfreewebs.net support php?

hotmail / yahoo are a little bit quirky when it comes to this kind of thing. There were days when I have gotten the email right away, and there were days where it took a couple hours, and I have actually had it take a full week before ... yes a full week.

but if your server does support php have a look at a few other things my guess is the reason its not submitting is because of this typo



<form action="http://nemesisclan.myfreewebs.net/sendeail.php" method="post">
is that supposed to be sendemail?



this wont prevent your code from submitting but you forgot to close this tag

<label style="FLOAT: left; WIDTH: 140px" for="name">Runescape Username:


you have a double ending quote, again i dont thing it will prevent the form from submitting but its a coding error nonetheless


<label style="FLOAT: left; WIDTH: 140px" for=ml">Mage Level:</label>

change to



<label style="FLOAT: left; WIDTH: 140px" for="ml">Mage Level:</label>

Harlem Of Nem
08-20-2007, 01:59 PM
ahhh right kk... I thought the extra things I told you might help...

1st) Thankyou for spotting but it is purposely sendeail...
2nd) I did not see the unclosed tag will try and edit that now...
3rd) I'm confused... in that code does the label codes matter? I never thought it did but thankyou anyway... I will just give it a go now...

Harlem Of Nem
08-20-2007, 02:08 PM
I have changed them but nothing has worked really...
My hosting provider does do PHP and its best one i can find...
To be honest I think its the second code that is faulty...
Maybe i havent closed my PHP tags up properly...

Harlem Of Nem
08-20-2007, 02:37 PM
Any other ideas people?

boogyman
08-20-2007, 02:45 PM
I'm confused... in that code does the label codes matter? I never thought it did but thankyou anyway... I will just give it a go now...
it does it the sense of your coding, because its an unclosed quote. So there is no guarantee that it will work as you intended 100&#37; of the time, because of that error.

as for the rest, the code is loaded with non-semantic and depreciated code,
the "transitional" doctype really stopped being useful 10yrs ago when standards were just becoming the "thing" to use,
XHTML isn't supported by IE, thus while it will render, it will be in quirks mode and you wont be able to use any of the special features available in XHTML, even though u weren't using any in the first place.


I do not mean to attack you, I am simply just attempting to give you some constructive criticism.

and I cant really see anything that stands out in your process code. It doesn't look like the problem is with the mail() function itself, so try to print out the results rather then send the email, and if you can view the results then it would have something to do with the server settings.

and on a side note... i notice that you have php code in both the form and the processing script... that means both of your pages need to have the .php extension, which would then make having 2 files redundant.
remove all of the php code from the initial form page and try that

and if you can, try to see what error you are getting