Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-24-2004, 10:47 PM Form Mail in php
Joobz's Avatar
Extreme Talker

Posts: 208
Location: DFW Texas
Trades: 0
Does anyone know where I can get a script (don't know php so can't write one on my own) where I can have a form for my site visitors to fill out? Something simple that would just capture Name (first and last) phone number and email address.
I have tried this one:

http://www.phpfreaks.com/tutorials/68/0.php

I copied every step in the tutorial down to the last detail but all I get when I test this is:
"Parse error: parse error in /home/uskipco/public_html/contact.php on line 90"

I don't need all of the fields in this particular script, I was just testing it to see if it works. If anyone needs to view the code, the form is listed here:
http://www.uskip.com/contact_form.htm

I checked the feedback threads at phpfreaks.com but didn't notice where anyone else had the same problem.
__________________

Please login or register to view this content. Registration is FREE
Joobz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-24-2004, 11:37 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Joobz,

HTML Code:
html>
<head><title>Test Form</title></head>
<body>

<form name="contactForm" method="POST" action="mailit.php">
        Name: <input type="text" name="username" size="30" /><br />
        Your Email Address:  <input type="text" name="email" size="30" 
/><br />
        Comments<br /><textarea name="comments" rows="7" 
cols="55"></textarea>

        <input type="Submit" value="Send" />
        <input type="Reset" value="Reset Form" />

    </form>
</body>

</html>
Now this is a simple PHP script (mailit.php) to execute the mail. You should do more research to ensure your site doesn't become an outlet for hackers.


EDIT: Had to break up the email address in the From: mail header to keep WT from putting a tag on it. So imagine all of that together, but it works the way it is, too.

PHP Code:
<html>
<head><title>Simple Mail</title></head>
<body>
<?php
 
$name 
$_POST[username];
$email $_POST[email];
$comments $_POST[comments];
 
if( empty( 
$email ) )
{
    print 
"Can't send email -- empty email address.";
}
/* Add other statements to check for valid message, valid email
address (contains '@'), etc. */
else
{
    
$bSuccess generateMail$name$email$comments );
 
    print 
"Mail sent " . ( $bSuccess "successfully." 
"unsuccessfully." );
    
 
}
 
?>
</body>
</html>
 
<?php
    
function generateMail$uname$emailAddress$comments )
    {
        
$mailHeaders "From:  me" "@" "mywebsite." "com \n";
        
$mailHeaders .= "Reply-To: " $emailAddress;
 
        
$msg "This is a web-originated email from user " $uname .
" whose email address is " $emailAddress;
        
$msg .= "\n\nComments:\n" $comments "\n\n";
 
        
$bResult mail"me@mywebsite.com""EMail Subject"$msg,
$mailHeaders );
 
        return 
$bResult;
 
    }
?>
__________________
—Kyrnt

Last edited by Kyrnt; 06-21-2005 at 07:19 AM..
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 06-25-2004, 12:48 PM
Joobz's Avatar
Extreme Talker

Posts: 208
Location: DFW Texas
Trades: 0
Quote:
Originally Posted by Kyrnt
You should do more research to ensure your site doesn't become an outlet for hackers.
Could you please explain?
__________________

Please login or register to view this content. Registration is FREE
Joobz is offline
Reply With Quote
View Public Profile
 
Old 06-25-2004, 12:50 PM
Joobz's Avatar
Extreme Talker

Posts: 208
Location: DFW Texas
Trades: 0
Quote:
Originally Posted by Kyrnt

Now this is a simple PHP script (mailit.php) to execute the mail. You should do more research to ensure your site doesn't become an outlet for hackers.
Would I save these 2 documents in php or htm?
__________________

Please login or register to view this content. Registration is FREE
Joobz is offline
Reply With Quote
View Public Profile
 
Old 06-25-2004, 01:00 PM
Unknown.

Posts: 1,693
Trades: 0
The first one can be saved in HTML....

But the second must be saved as PHP

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 06-25-2004, 01:06 PM
Novice Talker

Posts: 5
Trades: 0
I use attached PHP formmail script.
Previously I was using one cgi script which was exploit by spammer to send thousands of mails . But then this scipt is secure against this.
Attached Files
File Type: zip formmail.zip (5.9 KB, 30 views)
__________________

Please login or register to view this content. Registration is FREE
derek is offline
Reply With Quote
View Public Profile
 
Old 06-25-2004, 02:31 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Quote:
Originally Posted by Joobz
Could you please explain?
Sure. Some spammers / hackers (is there a difference in my book? Not really.) can setup scripts on their servers which will repeatedly send emails to you using your own web form -- kind of a targeted email just at you.

Some users have setup mechanisms in the PHP in which they write the IP address from which the mail request was sent to a database and if the same IP tries to send more than two in a row or maybe more than 5 in 5 minutes, etc., then the mail send request would be denied.

There are scripts out there you can find that have that kind of security built in or you could write it yourself.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 11-25-2004, 02:39 PM
Mekkahfire's Avatar
Novice Talker

Posts: 8
Trades: 0
I physically copied your entire script, and only changed the email address.... It still doesnt work. It says "email sent unsucessfully."

Also, i have another script sourced out to me by my friend...

-------------------------------------

<?
/*


$Id: phpscript.txt 3.3 2004/06/18 11:33:40 chris Exp $

*/

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "Mekkahfire@hotmail.com" ;

$mailto = 'Mekkahfire@hotmail.com' ;

// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;

$subject = "Rolling-Images membership" ;

// the pages to be displayed, eg
//$formurl = "http://www.example.com/feedback.html" ;
//$errorurl = "http://www.example.com/error.html" ;
//$thankyouurl = "http://www.example.com/thankyou.html" ;

$formurl = "http://www.rolling-images.com/join.html" ;
$errorurl = "http://www.rolling-images.com/joinerror.html" ;
$thankyouurl = "http://www.rolling-images.com/jointhankyou.html" ;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$carmake = $_POST['carmake'] ;
$color = $_POST['color'] ;
$year = $_POST['year'] ;
$whyjoin = $_POST['whyjoin'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) || empty($phone) || empty($carmake) || empty($color) || empty($year) || empty($whyjoin) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit ;

?>
--------------------------------------------
what the heck is wrong???
Mekkahfire is offline
Reply With Quote
View Public Profile
 
Old 11-26-2004, 09:45 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Actually, Mekka, that is the correct behavior if, for some reason uncontrollable by the script, something does not work correctly. Don't unconditionally indict the script as it has been used dozens of times by other users and completed tested by me.

There are a number of reasons it may not have worked -- your server may not allow the mail function to work. Anything that can cause the mail() function in PHP to return false will generate that message.

Easy on the sweeping statements -- this code has been up since last June!
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 11-26-2004, 05:07 PM
Mekkahfire's Avatar
Novice Talker

Posts: 8
Trades: 0
Sweeping statements? I meerly told you my problem... But thanks for the reply, im going to have to track down the problem i guess.
Mekkahfire is offline
Reply With Quote
View Public Profile
 
Old 07-12-2005, 07:03 AM mailHeaders
Junior Talker

Posts: 1
Trades: 0
hi,
could you tell me what the $mailHeaders command refers to. I get an error on that line of code when using the script. Do I need to enter a value for this,
thanks,
john
johnmce is offline
Reply With Quote
View Public Profile
 
Old 07-12-2005, 07:46 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
Quote:
spammers / hackers (is there a difference in my book? Not really.)
Spammer: Someone who creates bulk ammounts of traffic, usually e-mail advertisments.
Hacker: A clever programmer.
Cracker: A cracker is someone who breaks into someone else's computer system.

Source: http://www.whatis.com
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 07-12-2005, 08:45 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Minaki you learned how to use a keyboard yet?



Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Reply     « Reply to Form Mail in php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39481 seconds with 13 queries