1) When sending an e-mail with PHP, how is a Character Return done?
2) Any recommendation on a captcha that can handle more than one validation at once? The Captcha I'm trying to use now simply gets confused too easily.
3) How to I make a string all lower case or upper case?
Three Simple Questions
Moderator: General Moderators
Re: Three Simple Questions
1) How are you trying to send the email? MIME, HTML, Text? Just using the mail() ?Bigun wrote:1) When sending an e-mail with PHP, how is a Character Return done?
2) Any recommendation on a captcha that can handle more than one validation at once? The Captcha I'm trying to use now simply gets confused too easily.
3) How to I make a string all lower case or upper case?
3) http://us3.php.net/manual/en/function.m ... t-case.php <-- Should work for you... Worked for me..
Re: Three Simple Questions
Either or, I'm using the mail() function and attempting to send a small form letter. And character returns make it look pretty.labmixz wrote:1) How are you trying to send the email? MIME, HTML, Text? Just using the mail() ?Bigun wrote:1) When sending an e-mail with PHP, how is a Character Return done?
2) Any recommendation on a captcha that can handle more than one validation at once? The Captcha I'm trying to use now simply gets confused too easily.
3) How to I make a string all lower case or upper case?
3) http://us3.php.net/manual/en/function.m ... t-case.php <-- Should work for you... Worked for me..
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
1) Have you looked at the PHP mail function and what it can do? If not, have you looked at d11's Swift Mailer? There is a link in my sig or you can visit the Swift Mailer web site.
2) There are some resources available. You may want to google 'captcha multiple validations' and see what comes up.
3) strtoupper() or strtolower().
2) There are some resources available. You may want to google 'captcha multiple validations' and see what comes up.
3) strtoupper() or strtolower().
1, always CRLF
2, even the most basic captcha shouldn't have this trouble. Here's a really really simple one to whet your appitite. Just spice up the image to your liking... or check out my captcha with audio back up.
Code: Select all
echo "\r\n";Code: Select all
<?php
session_start();
if(isset($_GET['i'])){
// image creation section
captcha_image();
}elseif(isset($_POST['captcha'])){
// validation section
echo(captcha_validate())?'That was correct.<br>':'That was not correct.<br>';
echo '<a href="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'">Try another?</a>';
exit;
}else{
// form section
echo
'<p><a href="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].
'" onclick="document.getElementById(\'captcha\').src=\'http://'.
$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].
'?i=\' + new Date; return false;">Give me an easier one!</a></p>'."\n".
'<p><img id="captcha" src="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].
'?i='.uniqid().'" alt=""></p>'."\n".
'<form action="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'" method="POST">'."\n".
'<input type="text" name="captcha" ><input type="submit" value="test it"></form>';
}
function captcha_validate()
{
if($_POST['captcha'] == $_SESSION['captcha'])
{
$_SESSION['captcha'] = null;
return true;
}
return false;
}
function captcha_image($length =
{
$fontsize = 5;
$_SESSION['captcha'] = substr(base64_encode(md5(rand())), 0, $length);
$image = imagecreate(($length*imagefontwidth($fontsize))+1, imagefontheight($fontsize)+1);
$background_colour = imagecolorallocate($image, 255,255,255);
$text_shadow = imagecolorallocate($image, 127,127,127);
$text_colour = imagecolorallocate($image, 0,0,0);
imagestring($image, $fontsize, 1, 1, $_SESSION['captcha'], $text_shadow);
imagestring($image, $fontsize, 0, 0, $_SESSION['captcha'], $text_colour);
header ('Content-type: image/png');
imagepng($image);
imagedestroy($image);
exit;
}
?>