View Full Version : Technical question...

08-16-2009, 12:43 AM
Hey guys, I have been at this for about 10 hrs and can't find a solution. Your help will be appreciated. Thanks

I have a mail form with a captcha feature. when tested locally it works great, however, when testing on remote server, the script keeps adding the image path twice and I can't find the reason.

Here's the code:

// Where to redirect after form is processed.
$url = 'http://www.car4students.com/contact.php';

$to = "info@car4students.com";
$subject = "Email from website";
$message = $_REQUEST["body"];
$subject = $_REQUEST["subject"];
$email = $_REQUEST["email"];

function is_valid_email($email) {
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email);
include_once $_SERVER['DOCUMENT_ROOT'] .'/car4students\c4site\securimage\securimage.php';

$securimage = new Securimage();

if ($securimage->check($_POST['captcha_code']) == false) {
// the code was incorrect
// handle the error accordingly with your other error checking

// or you can do something really basic like this
die('Oops. The code you entered was incorrect. Please go back and try again.');

if (!is_valid_email($email)) {
echo 'Sorry, invalid email. Please go back and imput correct e-mail';

$headers = "From: $email";
mail($to, $subject, $message, $headers);
echo "Thanks for submitting.";
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';


And this is what I keep getting back:

Warning: include_once(d:\hosting\member\car4students\c4site d:\hosting\member/car4students\c4site\securimage\securimage.php) [function.include-once (http://car4students.com/function.include-once)]: failed to open stream: Invalid argument in D:\hosting\member\car4students\c4site\sndemail.php on line 21

Warning: include_once() [function.include (http://car4students.com/function.include)]: Failed opening 'd:\hosting\member\car4students\c4sited:\hosting\m ember/car4students\c4site\securimage\securimage.php' for inclusion (include_path='.;C:\php5\pear') in D:\hosting\member\car4students\c4site\sndemail.php on line 21

Fatal error: Class 'Securimage' not found in D:\hosting\member\car4students\c4site\sndemail.php on line 23

08-16-2009, 01:04 AM
O.K. guys, I found the solution. I needed to remove the word "Root" from include_once. However, the script, upon trying to send to e-mail returns this:

Warning: mail() [function.mail (http://car4students.com/function.mail)]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\hosting\member\car4students\c4site\test.php on line 46

I am not in a "local server" to verify in php.ini. any suggestions? Thanks