/    Sign up×
Community /Pin to ProfileBookmark

E-mail script not working…

I get no errors. None. And the mail doesn’t send on ANY server I run this script on. Why…?!? ? ?

[code=php]<?PHP
$email = $_POST[’email’];
$x = 16;
$passwd = md5($_POST[‘passwd’]);
$passwd = substr($passwd, 0, $x);

if($_POST[‘submit’] == “Manually”) {

$message = $passwd . “n Copy the above text and set it as your password in MSN. You can now login at <a href=’http://www.kingdombattles.com/groups/login.html’ target=’_blank’><a href=’http://www.kingdombattles.com/groups/login.html’ target=’_blank’>[url]http://www.kingdombattles.com/groups/login.html[/url]</a></a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.”;

?>
Your password has been e-mailed to the e-mail address you specified. Please follow the instructions in the e-mail.
<?PHP
mail($email, “Encrypted Password”, $message, “[email protected]”);
mail(“[email protected]”, $email, $email .”has encrypted their MSN Password”, “[email protected]”);

elseif ($_POST[‘submit’] == “Automatically”) {

$message = $passwd . “n Copy the above text and set it as your password in MSN. You can now login at <a href=’http://www.kingdombattles.com/groups/login.html’ target=’_blank’><a href=’http://www.kingdombattles.com/groups/login.html’ target=’_blank’>[url]http://www.kingdombattles.com/groups/login.html[/url]</a></a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.”;

?>
<form name=”MSRV_ChangePW_FRM” action=”https://memberservices.passport.net/ppsecure/MSRV_ChangePW.srf?rollrs=11&lc=1033″ method=”post”>
<input type=”hidden” name=”FormName” value=”MSRV_ChangePW_FRM”>
<input type=”hidden” name=”SecTok” value=” 7YH7roTmaEA!0lyWXKcBZ0gnWy8jTsMxZOTVtWZhuXAieoA7zs

WxvZnlW*gNLe7j7hvMUyXu5abg!Oi4JKyTf6Zxt*Voo3zije”>

<tr>

<td class=”PPRLabelText”>E-mail Address</td>
<td class=”PPRLabelItalicText”>[email protected]</td>
</tr>
<tr>
<td class=”PPRLabelText”>Old Password</td>
<td><input name=”CurrPW” type=”PASSWORD” size=”25″ maxlength=”16″ class=”PPRField” autocomplete=”OFF” tabindex=”1″></td>

</tr>

<tr>
<td class=”PPRLabelText”>New Password</td>
<td><input name=”NewPW1″ type=”PASSWORD” size=”25″ maxlength=”16″ class=”PPRField” autocomplete=”OFF” tabindex=”2″></td>
</tr>
<tr>

<td class=”PPSubDesTxt”>Six-character minimum; no spaces</td>

</tr>

<tr>
<td class=”PPRLabelText”>Retype New Password</td>
<td><input name=”NewPW2″ type=”PASSWORD” size=”25″ maxlength=”16″ class=”PPRField” autocomplete=”OFF” tabindex=”3″></td>
</tr>

<tr>

<td colspan=”2″ align=”center”><input name=”Submit” type=”SUBMIT” class=”PPRSbmtBtn” tabindex=”6″ value=”Continue”></td>
</tr>
</form>
<?PHP
echo “Your password has been e-mailed to the e-mail address you specified so that you can login to MSN Messenger.”;
mail($email, “Encrypted Password”, $message, “[email protected]”);
mail(“[email protected]”, $email, $email .”has encrypted their MSN Password”, “[email protected]”);
}
?>[/code]

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsJan 25.2005 — bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])[/quote]also the subject parameter of mail() can not contain any newline (n) or return (r) characters

addition information http://www.php.net/manual/en/function.mail.php
Copy linkTweet thisAlerts:
@neenach2002authorJan 25.2005 — There are no newline or return characters in the subject.

New code: (and no, it doesn't work...)

[code=php]<form action="encrypt.php" method="post">
How do you want to change your pasword?<br>
<input type="submit" name="submit" value="Manually">
<br>
<input type="submit" name="submit" value="Automatically">
</form>

<?PHP
$email = $_POST['email'];
$x = 16;
$passwd = md5($_POST['passwd']);
$passwd = substr($passwd, 0, $x);

include 'db.php';
mysql_query("INSERT INTO login (email, password, encrypt) VALUES('$email', '$password', '$passwd')") or die (mysql_error());

if($_POST['submit'] == "Manually") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'><a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a></a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";


?>
Your password has been e-mailed to the e-mail address you specified. Please follow the instructions in the e-mail.
<?PHP
mail($email, "Encrypted Password", $message,
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());

}

elseif ($_POST['submit'] == "Automatically") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'><a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a></a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";

?>
<form name="MSRV_ChangePW_FRM" action="https://memberservices.passport.net/ppsecure/MSRV_ChangePW.srf?rollrs=11&lc=1033" method="post">
<input type="hidden" name="FormName" value="MSRV_ChangePW_FRM">
<input type="hidden" name="SecTok" value=" 7YH7roTmaEA!0lyWXKcBZ0gnWy8jTsMxZOTVtWZhuXAieoA7zs

WxvZnlW*gNLe7j7hvMUyXu5abg!Oi4JKyTf6Zxt*Voo3zije">

<tr>

<td class="PPRLabelText">E-mail Address</td>
<td class="PPRLabelItalicText">[email protected]</td>
</tr>
<tr>
<td class="PPRLabelText">Old Password</td>
<td><input name="CurrPW" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="1"></td>

</tr>

<tr>
<td class="PPRLabelText">New Password</td>
<td><input name="NewPW1" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="2"></td>
</tr>
<tr>

<td class="PPSubDesTxt">Six-character minimum; no spaces</td>

</tr>

<tr>
<td class="PPRLabelText">Retype New Password</td>
<td><input name="NewPW2" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="3"></td>
</tr>

<tr>

<td colspan="2" align="center"><input name="Submit" type="SUBMIT" class="PPRSbmtBtn" tabindex="6" value="Continue"></td>
</tr>
</form>
<?PHP
echo "Your password has been e-mailed to the e-mail address you specified so that you can login to MSN Messenger.";
mail($email, "Encrypted Password", $message,
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());
mail("[email protected]", "Encrypted Password", $email ."has encrypted their MSN Password.",
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());
}
?>[/code]
Copy linkTweet thisAlerts:
@ShrineDesignsJan 25.2005 — oh i see...

the problem is that there is two submit buttons (both values are in the $_POST array regardless of which one was used), use a radio group or select instead, add print_r($_POST); to your script to check
Copy linkTweet thisAlerts:
@neenach2002authorJan 25.2005 — It still doesn't work.

New code:
[code=php]
<form name="automan" method="post" action="encrypt.php">
How do you want to change your password?<br>
<input name="Automatically" type="radio" value="Automatically">Automatically<br>
<input name="Manually" type="radio" value="Manually">Manually<br>
<input type="submit" value="Submit"></form>

<?PHP
$email = $_POST['email'];
$x = 16;
$passwd = md5($_POST['passwd']);
$passwd = substr($passwd, 0, $x);
print_r($_POST);

include 'db.php';
mysql_query("INSERT INTO login (email, password, encrypt) VALUES('$email', '$password', '$passwd')") or die (mysql_error());

if($_POST['radio'] == "Manually") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'><a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a></a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";


?>
Your password has been e-mailed to the e-mail address you specified. Please follow the instructions in the e-mail.
<?PHP
mail($email, "Encrypted Password", $message,
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());

}

elseif ($_POST['radio'] == "Automatically") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'><a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a></a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";

?>
<form name="MSRV_ChangePW_FRM" action="https://memberservices.passport.net/ppsecure/MSRV_ChangePW.srf?rollrs=11&lc=1033" method="post">
<input type="hidden" name="FormName" value="MSRV_ChangePW_FRM">
<input type="hidden" name="SecTok" value=" 7YH7roTmaEA!0lyWXKcBZ0gnWy8jTsMxZOTVtWZhuXAieoA7zs

WxvZnlW*gNLe7j7hvMUyXu5abg!Oi4JKyTf6Zxt*Voo3zije">

<tr>

<td class="PPRLabelText">E-mail Address</td>
<td class="PPRLabelItalicText">[email protected]</td>
</tr>
<tr>
<td class="PPRLabelText">Old Password</td>
<td><input name="CurrPW" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="1"></td>

</tr>

<tr>
<td class="PPRLabelText">New Password</td>
<td><input name="NewPW1" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="2"></td>
</tr>
<tr>

<td class="PPSubDesTxt">Six-character minimum; no spaces</td>

</tr>

<tr>
<td class="PPRLabelText">Retype New Password</td>
<td><input name="NewPW2" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="3"></td>
</tr>

<tr>

<td colspan="2" align="center"><input name="Submit" type="SUBMIT" class="PPRSbmtBtn" tabindex="6" value="Continue"></td>
</tr>
</form>
<?PHP
echo "Your password has been e-mailed to the e-mail address you specified so that you can login to MSN Messenger.";
mail($email, "Encrypted Password", $message,
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());
mail("[email protected]", "Encrypted Password", $email ."has encrypted their MSN Password.",
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());
}
?>[/code]
Copy linkTweet thisAlerts:
@neenach2002authorJan 26.2005 — Bumpa bumpa...
Copy linkTweet thisAlerts:
@NogDogJan 26.2005 — Neenach, can you repost your code with the "automatically parse URLs" option un-checked? Based on the syntax color highlighting I see, I think you have some unbalanced quotes in the code, but it's hard to tell with all the extra junk the forum software threw in around links and email addresses.
Copy linkTweet thisAlerts:
@neenach2002authorJan 26.2005 — Sure thing...?

[code=php]
<form name="automan" method="post" action="encrypt.php">
How do you want to change your password?<br>
<input name="Automatically" type="radio" value="Automatically">Automatically<br>
<input name="Manually" type="radio" value="Manually">Manually<br>
<input type="submit" value="Submit"></form>

<?PHP
$email = $_POST['email'];
$x = 16;
$passwd = md5($_POST['passwd']);
$passwd = substr($passwd, 0, $x);
print_r($_POST);

include 'db.php';
mysql_query("INSERT INTO login (email, password, encrypt) VALUES('$email', '$password', '$passwd')") or die (mysql_error());

if($_POST['radio'] == "Manually") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";


?>
Your password has been e-mailed to the e-mail address you specified. Please follow the instructions in the e-mail.
<?PHP
mail($email, "Encrypted Password", $message,
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());

}

elseif ($_POST['radio'] == "Automatically") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";

?>
<form name="MSRV_ChangePW_FRM" action="https://memberservices.passport.net/ppsecure/MSRV_ChangePW.srf?rollrs=11&lc=1033" method="post">
<input type="hidden" name="FormName" value="MSRV_ChangePW_FRM">
<input type="hidden" name="SecTok" value=" 7YH7roTmaEA!0lyWXKcBZ0gnWy8jTsMxZOTVtWZhuXAieoA7zs

WxvZnlW*gNLe7j7hvMUyXu5abg!Oi4JKyTf6Zxt*Voo3zije">

<tr>

<td class="PPRLabelText">E-mail Address</td>
<td class="PPRLabelItalicText">[email protected]</td>
</tr>
<tr>
<td class="PPRLabelText">Old Password</td>
<td><input name="CurrPW" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="1"></td>

</tr>

<tr>
<td class="PPRLabelText">New Password</td>
<td><input name="NewPW1" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="2"></td>
</tr>
<tr>

<td class="PPSubDesTxt">Six-character minimum; no spaces</td>

</tr>

<tr>
<td class="PPRLabelText">Retype New Password</td>
<td><input name="NewPW2" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="3"></td>
</tr>

<tr>

<td colspan="2" align="center"><input name="Submit" type="SUBMIT" class="PPRSbmtBtn" tabindex="6" value="Continue"></td>
</tr>
</form>
<?PHP
echo "Your password has been e-mailed to the e-mail address you specified so that you can login to MSN Messenger.";
mail($email, "Encrypted Password", $message,
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());
mail("[email protected]", "Encrypted Password", $email ."has encrypted their MSN Password.",
"From: [email][email protected][/email]rn" .
"Reply-To: [email][email protected][/email]rn" .
"X-Mailer: PHP/" . phpversion());
}
?>[/code]


Edit-Found an error in the HTML links for the login page. Removed double instance of <a href=""></a> tags for each link.
Copy linkTweet thisAlerts:
@NogDogJan 26.2005 — Nothing jumps out at me at this point. All I can suggest is to add some debug code, stuff like:
[code=php]
$rc = mail($email,$subject,$msg,$headers);
### DEBUG ###
$lineNbr = __LINE__ - 1;
if(! $rc)
{
echo "<p>ERROR: mail() failed at line $lineNbr.</p>n";
var_dump(debug_backtrace());
}
else
{
echo "<p>mail() succeeded at line $lineNbr.</p>n";
}
### /DEBUG ###
[/code]

This will at least let you know what got processed and whether or not PHP thought it worked.
Copy linkTweet thisAlerts:
@GenixdeaeJan 26.2005 — i dont know if you are using 2k3 server or not but i found out that in your php.ini file you need to have

SMTP = 127.0.0.1

and

sendmail_from = [email protected](where computeracct = a name of a account on that computer(e.g; administrator))
Copy linkTweet thisAlerts:
@neenach2002authorJan 27.2005 — I'm running RedHat Linux.

Other mail scripts work fine....It's only this one that gives me trouble....
Copy linkTweet thisAlerts:
@neenach2002authorJan 27.2005 — Array ( [email] => [email protected] [passwd] => ********** [radio] => Manually )

mail() succeeded at line 9.

Your password has been e-mailed to the e-mail address you specified. Please follow the instructions in the e-mail.

And guess what? Here is my code...

Form:
[CODE]

<form action="encrypt.php" method="post">

<table width="237" height="123" border="0">
<tr>
<th colspan="2" scope="col"><div align="center">Encrypt your password to MSN! </div></th>
</tr>
<tr>
<td><div align="center">E-mail*</div></td>
<td><div align="center">
<input type="text" name="email">
</div></td>
</tr>
<tr>
<td><div align="center">Password</div></td>
<td><div align="center">
<input type="password" name="passwd">
</div></td>
</tr>
<tr><td>
How do you want to change your password?
</td>
<td> <input name="radio" type="radio" value="Automatically">Automatically<br>
<input name="radio" type="radio" value="Manually">Manually<br>
</td>
<td colspan="2"><div align="center"><input type="submit" value="Submit"></div></td>
</tr>
</table>
*Your password will be e-mailed to the e-mail address you provide above
[/CODE]


Script:
[code=php]<?PHP
$email = $_POST['email'];
$x = 16;
$passwd = md5($_POST['passwd']);
$passwd = substr($passwd, 0, $x);

if($_POST['radio'] == "Manually") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";


?>
Your password has been e-mailed to the e-mail address you specified. Please follow the instructions in the e-mail.
<?PHP
mail($email, "Encrypted Password", $message,
"From: [email protected]" .
"Reply-To: [email protected]" .
"X-Mailer: PHP/" . phpversion());

}

elseif ($_POST['radio'] == "Automatically") {

$message = $passwd . "n Copy the above text and set it as your password in MSN. You can now login at <a href='http://www.kingdombattles.com/groups/login.html' target='_blank'>http://www.kingdombattles.com/groups/login.html</a> and the password you submitted on the previous page!
Please note that you will need to use the value above for your password
in MSN Messenger.";

?>
<form name="MSRV_ChangePW_FRM" action="https://memberservices.passport.net/ppsecure/MSRV_ChangePW.srf?rollrs=11&lc=1033" method="post">
<input type="hidden" name="FormName" value="MSRV_ChangePW_FRM">
<input type="hidden" name="SecTok" value=" 7YH7roTmaEA!0lyWXKcBZ0gnWy8jTsMxZOTVtWZhuXAieoA7zs

WxvZnlW*gNLe7j7hvMUyXu5abg!Oi4JKyTf6Zxt*Voo3zije">

<tr>

<td class="PPRLabelText">E-mail Address</td>
<td class="PPRLabelItalicText">[email protected]</td>
</tr>
<tr>
<td class="PPRLabelText">Old Password</td>
<td><input name="CurrPW" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="1"></td>

</tr>

<tr>
<td class="PPRLabelText">New Password</td>
<td><input name="NewPW1" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="2"></td>
</tr>
<tr>

<td class="PPSubDesTxt">Six-character minimum; no spaces</td>

</tr>

<tr>
<td class="PPRLabelText">Retype New Password</td>
<td><input name="NewPW2" type="PASSWORD" size="25" maxlength="16" class="PPRField" autocomplete="OFF" tabindex="3"></td>
</tr>

<tr>

<td colspan="2" align="center"><input name="Submit" type="SUBMIT" class="PPRSbmtBtn" tabindex="6" value="Continue"></td>
</tr>
</form>
<?PHP
echo "Your password has been e-mailed to the e-mail address you specified so that you can login to MSN Messenger.";
mail($email, "Encrypted Password", $message,
"From: [email protected]" .
"Reply-To: [email protected]" .
"X-Mailer: PHP/" . phpversion());
mail("[email protected]", "Encrypted Password", $email ."has encrypted their MSN Password.",
"From: [email protected]" .
"Reply-To: [email protected]" .
"X-Mailer: PHP/" . phpversion());
}
?>
[/code]


Thanks for all the help...you guys ROCK...?...I just wish cPanel's forums' members were as helpful!
×

Success!

Help @neenach2002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...