Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
boomboom is on a distinguished road
 
Posts: 3
Join Date: May 2009
Default about form to email - 05-16-2009, 10:00 AM

Can anyone help me or direct me to any tutorials about adding an form to email to my site. I tried adding a form to email that gets the name, email and the message of the user and then sends it to my email but its not working, it says HTTP Error 403 Forbidden. Is form to email not supported in free hosting? Someone enlighten me here, not really good at this kind of stuff but I just want to have personal site.
Reply With Quote
(#2 (permalink))
Old
Junior Member
diesler is on a distinguished road
 
Posts: 24
Join Date: May 2009
Default 05-16-2009, 05:19 PM

You can get one from this website, which is easy to use.

1) Download BELLonline-mailer.zip
2) Extract the .zip file to your computer
3) Open config.php and change "changeme@example.com" to your own email adres.
4) Upload BELLmailer.php and config.php to the root of your website.
4) Type the adres in your browser http://<your domain>/BELLmailer.php

This should work.....

if you want to show the form on another page (must be a .php page) add the code <?php include "BELLmailer.php"; ?> to it.

leave me a note if you got any problems with it.
Reply With Quote
(#3 (permalink))
Old
bigal's Avatar
Senior Member
bigal is an unknown quantity at this point
 
Posts: 183
Join Date: Mar 2009
Location: Brisbane, Australia
Default 05-17-2009, 12:38 AM

I wrote a small form to do what you wanted, with comments explaining the code.
This is a very simple form, and does not do any validation on input fields.
Note that depending on what you enter in as SENDEMAIL, it could end up as SPAM email in your SPAM or JUNK mail folder.

PHP Code:
<?php
define
('RECIPIENTEMAIL','test@gmail.com');  // define your email (Recipient) here.
define('SENDEREMAIL','NoReply@gmail.com'); // define Senderemail here (Shows as Sender's email)
if (isset($_POST['submit']) ){ // check if submit button is clicked
  
$name 'From: '.$_POST['name']."\r\n"// name valaue in email body as first line.
  
$email 'Email: '.$_POST['email']."\r\n"// email value in email body as second line.
  
$body $name.$email.$_POST['message']; // body first line, second line plus message
  
$subject 'Web Message'// shows as subject in email
  
$to RECIPIENTEMAIL
  
$header 'From: '.SENDEREMAIL."\r\n";
  if (@
mail($to$subject$body$header)){ // PHP mail function to send email.
    
echo '<b>Message send succeed</b><br />';
  }else{
    echo 
'<b>Message send failed</b><br />';
  }
}
// a form to collect user name, email and message
echo '<table><form action="'.$_SERVER[PHP_SELF].'" method="post">
<tr><td><label>Name</label></td><td><input type="text" name="name"></td></tr>
<tr><td><label>Email</label></td><td><input type="text" name="email"></td></tr>
</table>'
;
echo 
'<table>
<tr><td><label>Message</label></tr>
<tr><td><textarea name="message" cols=50 rows=8></textarea></td></tr>
<tr><td align="right"><input type="submit" name="submit" value="Send Message"></td></tr></table>
</form>'

?>
Reply With Quote
(#4 (permalink))
Old
Junior Member
boomboom is on a distinguished road
 
Posts: 3
Join Date: May 2009
Default 05-18-2009, 01:10 PM

Quote:
Originally Posted by diesler View Post
You can get one from this website, which is easy to use.

1) Download BELLonline-mailer.zip
2) Extract the .zip file to your computer
3) Open config.php and change "changeme@example.com" to your own email adres.
4) Upload BELLmailer.php and config.php to the root of your website.
4) Type the adres in your browser http://<your domain>/BELLmailer.php

This should work.....

if you want to show the form on another page (must be a .php page) add the code <?php include "BELLmailer.php"; ?> to it.

leave me a note if you got any problems with it.
This means the page must be in php right? I already have the forms ready, but it is in html format.
Reply With Quote
(#5 (permalink))
Old
Junior Member
boomboom is on a distinguished road
 
Posts: 3
Join Date: May 2009
Default 05-18-2009, 01:19 PM

To bigal,
thanks for writing the code, how can i make it work? Should I just save it as contact.php and save it at the root folder? what if I already have an existing html page?
Reply With Quote
(#6 (permalink))
Old
bigal's Avatar
Senior Member
bigal is an unknown quantity at this point
 
Posts: 183
Join Date: Mar 2009
Location: Brisbane, Australia
Default 05-18-2009, 01:46 PM

Yes, you can name it contact.php and call it.
You better test it first to see if it works for you, then modify the script to suit your needs
Reply With Quote
(#7 (permalink))
Old
Junior Member
wren99 is on a distinguished road
 
Posts: 3
Join Date: Jul 2009
Default Quick php question - 07-10-2009, 06:26 PM

What does "echo" mean? Why does it precede the html form?
(Sorry, I don't know anything about php yet).


Quote:
Originally Posted by bigal View Post
I wrote a small form to do what you wanted, with comments explaining the code.
This is a very simple form, and does not do any validation on input fields.
Note that depending on what you enter in as SENDEMAIL, it could end up as SPAM email in your SPAM or JUNK mail folder.

PHP Code:
<?php
define
('RECIPIENTEMAIL','test@gmail.com');  // define your email (Recipient) here.
define('SENDEREMAIL','NoReply@gmail.com'); // define Senderemail here (Shows as Sender's email)
if (isset($_POST['submit']) ){ // check if submit button is clicked
  
$name 'From: '.$_POST['name']."\r\n"// name valaue in email body as first line.
  
$email 'Email: '.$_POST['email']."\r\n"// email value in email body as second line.
  
$body $name.$email.$_POST['message']; // body first line, second line plus message
  
$subject 'Web Message'// shows as subject in email
  
$to RECIPIENTEMAIL
  
$header 'From: '.SENDEREMAIL."\r\n";
  if (@
mail($to$subject$body$header)){ // PHP mail function to send email.
    
echo '<b>Message send succeed</b><br />';
  }else{
    echo 
'<b>Message send failed</b><br />';
  }
}
// a form to collect user name, email and message
echo '<table><form action="'.$_SERVER[PHP_SELF].'" method="post">
<tr><td><label>Name</label></td><td><input type="text" name="name"></td></tr>
<tr><td><label>Email</label></td><td><input type="text" name="email"></td></tr>
</table>'
;
echo 
'<table>
<tr><td><label>Message</label></tr>
<tr><td><textarea name="message" cols=50 rows=8></textarea></td></tr>
<tr><td align="right"><input type="submit" name="submit" value="Send Message"></td></tr></table>
</form>'

?>
Reply With Quote
(#8 (permalink))
Old
bigal's Avatar
Senior Member
bigal is an unknown quantity at this point
 
Posts: 183
Join Date: Mar 2009
Location: Brisbane, Australia
Default 07-10-2009, 06:43 PM

'echo' is the print display command in php. If you want to leave 'echo' out you put html codes outside of the <?php ?> tag
Reply With Quote
(#9 (permalink))
Old
Junior Member
wren99 is on a distinguished road
 
Posts: 3
Join Date: Jul 2009
Default 07-10-2009, 06:54 PM

Do you know a way to use your php, but to avoid spam (i.e. add some sort of spam protection)?
Reply With Quote
(#10 (permalink))
Old
bigal's Avatar
Senior Member
bigal is an unknown quantity at this point
 
Posts: 183
Join Date: Mar 2009
Location: Brisbane, Australia
Default 07-10-2009, 07:24 PM

Add a captcha. Request for a security code, then match the code.

gdimage.php - this will create 4 image codes. you can amend to have different length
in $random_text = substr(md5(uniqid()),0,4);
PHP Code:
<?php  
session_start
(); 
header("Content-type: image/png");  
$im = @imagecreate(8020)  
    or die(
"Cannot Initialize new GD image stream");  
$background_color imagecolorallocate($im000);  
$text_color imagecolorallocate($im2331491);  
$random_text substr(md5(uniqid()),0,4); 
imagestring($im555,  $random_text$text_color);  
imagepng($im);  
$_SESSION['verify'] = $random_text
?>
contact.php -- uses session to remember random text generated by gdimage.
PHP Code:
<?php 
session_start
(); 
define('RECIPIENTEMAIL','test@gmail.com');  // define your email (Recipient) here. 
define('SENDEREMAIL','NoReply@gmail.com'); // define Senderemail here (Shows as Sender's email) 
if (isset($_POST['submit'])){ // check if submit button is clicked
  
if ($_SESSION['verify'] == $_POST['security_code']){
    
$name 'From: '.$_POST['name']."\r\n"// name valaue in email body as first line. 
    
$email 'Email: '.$_POST['email']."\r\n"// email value in email body as second line. 
    
$body $name.$email.$_POST['message']; // body first line, second line plus message 
    
$subject 'Web Message'// shows as subject in email 
    
$to RECIPIENTEMAIL;  
    
$header 'From: '.SENDEREMAIL."\r\n"
    if (@
mail($to$subject$body$header)){ // PHP mail function to send email. 
      
echo '<b>Message send succeed</b><br />'
      unset( 
$_SESSION['verify'] ); 
    }else{ 
      echo 
'<b>Message send failed</b><br />'
      unset( 
$_SESSION['verify'] ); 
    } 
  }else{  
// if not sercity code
    
echo '<font color="red"> Sorry, email can not continue..<br />  
        You have provided an invalid security code</font><br />'

  }
}
// a form to collect user name, email and message 
echo '<table><form action="'.$_SERVER['PHP_SELF'].'" method="post"> 
<tr><td><label>Name</label></td><td><input type="text" name="name"></td></tr> 
<tr><td><label>Email</label></td><td><input type="text" name="email"></td></tr> 
</table>'

echo 
'<table> 
<tr><td><label>Message</label></tr> 
<tr><td><textarea name="message" cols=50 rows=8></textarea></td></tr> 
</table>
<table>
<tr><td>Security Code</td><td><img src="gdimage.php" /></td></tr> 
<tr><td>Enter Security Code</td><td><input name="security_code" type="text" size="8" /> 
<tr><td align="right"><input type="submit" name="submit" value="Send Message"></td></tr></table> 
</form>'
;  
?>

Last edited by bigal; 07-13-2009 at 02:42 AM. Reason: missing ' around PHP_SELF
Reply With Quote
Reply

Thread Tools
Display Modes

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




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com