Lost Password?


  #1 (permalink)  
Old 02-08-2007, 02:57 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default Email form v2

Well now i'm gonna show how to make a email form, but without Email: field, cuz you will select a member who is in your database and then you can send an email to him/her. Let's start!

connect.php

PHP Code:
<?php
$host 
"localhost";
$db_user "YourUsername";
$db_pass "YourPassword";
$db "YourDatabase";

$connect mysql_connect($host$db_user$db_pass);
if(!
$connect){
die(
"Can not connect to database: ".mysql_error());
}

$select mysql_select_db($db$connect);
if(!
$select){
die(
"Can not select a database: ".mysql_error());
}
?>
now let's make this form..

index.php

PHP Code:
<?php
include("connect.php");

// Display your email form
function form(){

echo 
"<form action='?act=send' method='post'>
    <table width='400' border='1'>
    <tr>
    <td width='50%'>Send an email to: 
            <select name='users' size='1'>
            <option selected></option>"
;
            
// Make a dropdown menu where are all your users with their emails            
$item mysql_query("SELECT * FROM users");
while(
$row mysql_fetch_array($item)){
echo 
"<option value='".$row['email']."'>".$row['username']."</option>";
}
echo 
"</select>
    </td>
    </tr>
    <tr>
    <td>"
;
echo 
"Your name: <input type='text' name='from' size='30'>
    </td>
    </tr>
    <tr>
    <td>"
;
echo 
"Subject: <input type='text' name='subject' size='30'><br>
    </td>
    </tr>
    <tr>
    <td>"
    
."Message:<br><textarea cols='50' rows='10' name='text'></textarea>
    </td>
    </tr>
    <tr>
    <td>"
;
echo 
"<input type='submit' value='Send'>
    </td>
    </tr>
    </table>
    </form>"
;

}

function 
send(){

// Let's collect our info
$email $_REQUEST['users'];
$subject $_REQUEST['subject'];
$message $_REQUEST['text'];
$from $_REQUEST['from'];

// If something is not filled then let's display errors
if(empty($email)){
die(
"Please enter a person who will get this email!");
}

if(empty(
$subject)){
die(
"Please enter a subject!");
}

if(empty(
$message)){
die(
"Please enter your message!");
}

if(empty(
$from)){
die(
"Please enter your name!");
}

// If everything is okay let's send that email
mail($email$subject$message,"From: ".$from);
echo 
"Thank you! <a href='index.php'>Go back</a>";
}

switch(
$act){

default;
form();
break;

case 
"send";
send();
break;

}
?>
Have fun!
Attached Files To view attachments in this forum your post count must be 1 or greater. You currently have 0 posts.
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-22-2008, 01:29 AM
acidlake acidlake is offline
Newbie
 
Join Date: Jul 2008
Posts: 1
Rep Power: 0
acidlake is on a distinguished road
Smile Re: Email form v2

hi!is work? i really need it and i dont know how..hope this one works!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-22-2008, 11:10 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default Re: Email form v2

yes it works
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-22-2008, 12:36 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,583
Last Blog:
Web slideshow in JavaS...
Rep Power: 76
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Email form v2

Nar, of course it doesn't work...
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-23-2008, 02:31 PM
chili5's Avatar   
chili5 chili5 is offline
Code Warrior
 
Join Date: Mar 2008
Age: 15
Posts: 3,591
Rep Power: 31
chili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to all
Default Re: Email form v2

Wow that's really interesting and quite useful Thanks a bunch

Of course, you could use striptags() so the program doesn't read HTML that someone may enter.

Thanks a bunch
__________________
Emo Philips - "My computer beat me at checkers, but I sure beat it at kickboxing."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 07-23-2008, 03:04 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default Re: Email form v2

you're welcome
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-24-2008, 01:26 PM
chili5's Avatar   
chili5 chili5 is offline
Code Warrior
 
Join Date: Mar 2008
Age: 15
Posts: 3,591
Rep Power: 31
chili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to all
Default Re: Email form v2

Maybe some day, you could make a version of this, that sends HTML email?
__________________
Emo Philips - "My computer beat me at checkers, but I sure beat it at kickboxing."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-25-2008, 01:44 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default Re: Email form v2

it's a good idea.. i'll think about it
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding a change password form InternetGeek Visual Basic Programming 11 02-16-2008 02:53 PM
PHP:Tutorial - Email Verification John PHP Tutorials 3 09-19-2007 01:19 PM
Catch All Email Account Nightracer Computer Software/OS 4 11-17-2006 06:56 PM
Calling a form from another form Void Managed C++ 1 07-01-2006 10:44 AM


All times are GMT -5. The time now is 05:23 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads