Page 1 of 1
Three Simple Questions
Posted: Thu Jun 15, 2006 10:18 am
by Bigun
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?
Re: Three Simple Questions
Posted: Thu Jun 15, 2006 11:05 am
by labmixz
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?
1) How are you trying to send the email? MIME, HTML, Text? Just using the mail() ?
3)
http://us3.php.net/manual/en/function.m ... t-case.php <-- Should work for you... Worked for me..
Posted: Thu Jun 15, 2006 11:16 am
by poizn
cant answer the first two questions
but try these functions for question three
$string = strtoupper($string)
$string = strtolower($string)
hope this helps

Re: Three Simple Questions
Posted: Thu Jun 15, 2006 11:20 am
by Bigun
labmixz wrote: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?
1) How are you trying to send the email? MIME, HTML, Text? Just using the mail() ?
3)
http://us3.php.net/manual/en/function.m ... t-case.php <-- Should work for you... Worked for me..
Either or, I'm using the mail() function and attempting to send a small form letter. And character returns make it look pretty.

Posted: Thu Jun 15, 2006 11:28 am
by RobertGonzalez
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().
Posted: Thu Jun 15, 2006 12:00 pm
by bokehman
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
<?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;
}
?>