Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
Joined: May 2000
Posts: 3,143
P
Hard-core CEG'er
OP Offline
Hard-core CEG'er
P
Joined: May 2000
Posts: 3,143
I'm making a website for a client and I am trying to get a form that will use the sendmail funciton in PHP. I don't really know all that much about php, so this is a little over my head. I found a pretty simple form online, although it doesn't work whatsoever, and I have no idea what is wrong with it.

<form method="post" action="sendmail.php">
Name: <input name="name" type="text">
<br />
Email: <input name="email" type="text" />
<br />
Message:
<textarea name="message" rows="10" cols="30">
</textarea>
<input type="submit" />
</form>

<?
$email = $_POST['email'] ;
$message = $_POST['message'] ;
mail( webmaster@potsdamlacrosse.com, "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>

I'd also like to integrate an image verification function, so that the site doesn't get spammed to hell and back. I have that too, but I'd like to at least get the sendmial form working first.

TIA,
Pete


"Bros before Hoes" <-- More men need this mentality.
Joined: May 2000
Posts: 3,143
P
Hard-core CEG'er
OP Offline
Hard-core CEG'er
P
Joined: May 2000
Posts: 3,143
anyone?


"Bros before Hoes" <-- More men need this mentality.
Joined: Oct 2004
Posts: 1,177
C
Hard-core CEG\'er
Offline
Hard-core CEG\'er
C
Joined: Oct 2004
Posts: 1,177
Do you have sendmail correctly installed to the correct cgi bin ?

I'd check that first. I'm not hot on coding, myself, but it's pretty simple to setup so I'd check it's tehre okay first.


1998.5 T-Red on Midnight Blue SVT Build Number 5320 of 6535
Joined: May 2000
Posts: 3,143
P
Hard-core CEG'er
OP Offline
Hard-core CEG'er
P
Joined: May 2000
Posts: 3,143
Originally posted by Christian:
Do you have sendmail correctly installed to the correct cgi bin ?




/usr/sbin/sendmail -t -i


"Bros before Hoes" <-- More men need this mentality.
Joined: Dec 2001
Posts: 777
C
Veteran CEG\'er
Offline
Veteran CEG\'er
C
Joined: Dec 2001
Posts: 777
I'm not fully versed in PHP either, but are you certain that the webserver you are using handles php? And, does the php handler have permission to call sendmail? Do you have the ability to look at error logs?


>--------------< --Chemguru 99 CSVT Frost /Mid. Blue 00 Suzuki SV650 Red, Naked
Joined: May 2000
Posts: 3,143
P
Hard-core CEG'er
OP Offline
Hard-core CEG'er
P
Joined: May 2000
Posts: 3,143
Originally posted by chemguru:
I'm not fully versed in PHP either, but are you certain that the webserver you are using handles php? And, does the php handler have permission to call sendmail? Do you have the ability to look at error logs?




I know it runs php because other parts of the site use php, not to mention the hosting company says it does. They have a little ditty on their help section saying that sendmail is enabled. I also ran a php info and it looks OK (from what I gathered). When I tried running the above script it gave me a parse error.


"Bros before Hoes" <-- More men need this mentality.
Joined: Apr 2001
Posts: 9,442
B
Addicted CEG\'er
Offline
Addicted CEG\'er
B
Joined: Apr 2001
Posts: 9,442
Is all that on the same page????

The form itself should be in an HTML file, then the second half looks like it should be the response page (sendmail.php???)


www.ChicagoCEG.com 2006 White Grand Prix
Joined: Apr 2001
Posts: 9,442
B
Addicted CEG\'er
Offline
Addicted CEG\'er
B
Joined: Apr 2001
Posts: 9,442
This should be embedded somewhere in an HTML file....
Code:

<form method="post" action="sendmail.php">
Name: <input name="name" type="text">
<br />
Email: <input name="email" type="text" />
<br />
Message:<br />
<textarea name="message" rows="10" cols="30">
</textarea><br /><br />
<input type="submit" />
</form></center>
</body>



Then this should be copied and saved as sendmail.php with nothing else added to it...
Note the quotes around the E-mail address added also.
Code:

<?
$email = $_POST['email'] ;
$message = $_POST['message'] ;
mail( "webmaster@potsdamlacrosse.com", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>



The page I posted has the original E-mail address that you had in the original post...

If you need it changed for testing purposes let me know....
Heres Sendmail In Action to the E-mail address you supplied in the original post but from my server...

Also, I was using a script that takes you to an actual Thank You page, Might look a little more professional if for a buisness.

I've got it hosted over at http://www.chicagoceg.com for the time being so it'll be there until you tell me you don't need it anymore....


If you want me to post that just let me know...

Steve


www.ChicagoCEG.com 2006 White Grand Prix
Joined: Mar 2002
Posts: 140
F
CEG\'er
Offline
CEG\'er
F
Joined: Mar 2002
Posts: 140
do a ini_get('SMTP') to make absolutely certain the mail server it's trying to use is the right one.


1998 Contour SVT Toreador Red/Midnight Blue 3090/6535 1999 Contour SVT Black/Prairie Tan 18/2760 1992 Dodge Stealth R/T TT Metallic Beige/Tan 1989 Chrysler Conquest TSi Red/Black Leather
Joined: May 2000
Posts: 3,143
P
Hard-core CEG'er
OP Offline
Hard-core CEG'er
P
Joined: May 2000
Posts: 3,143
Thanks Steve, I have it up now on the site and it is working great. As a relative n00b I put the php in the same file that the form was in. If possible I'd like to work in some sort of image verificaiton to prevent spamming from bots. I know I'd have to change the original form from html to php, which I guess should be ok? I found this on the 'net but I'm not sure exactly how I would have the form capture the variables and whatnot. It has a lot of commenting from it's original owner. Please let me know what you think.

-Pete

<?php
session_start();

// make a string with all the characters that we
// want to use as the verification code
$alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

// generate the verication code
$rand = substr(str_shuffle($alphanum), 0, 5);

// choose one of four background images
$bgNum = rand(1, 4);

// create an image object using the chosen background
$image = imagecreatefromjpeg("background$bgNum.jpg");

$textColor = imagecolorallocate ($image, 0, 0, 0);

// write the code on the background image
imagestring ($image, 5, 5, 8, $rand, $textColor);


// create the hash for the verification code
// and put it in the session
$_SESSION['image_random_value'] = md5($rand);

// send several headers to make sure the image is not cached
// taken directly from the PHP Manual

// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");


// send the content type header so the image is displayed properly
header('Content-type: image/jpeg');

// send the image to the browser
imagejpeg($image);

// destroy the image to free up the memory
imagedestroy($image);
?>



"Bros before Hoes" <-- More men need this mentality.
Page 1 of 2 1 2

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5