Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 12th, 2007, 10:30 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert form data in an sql and email the content

hi everyone-

I need help submitting a form that will both submit the data to a sql database and email that info to me and another person. I have set the form up to submit the data to the sql db, but I am not sure how to email that data..

any help would be very much appreciated

Thanks
Reply With Quote
  #2 (permalink)  
Old February 13th, 2007, 03:17 AM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ddnk,

i hope this will help u.

<form method="post" action="sendmail.php">
Fist name :<input type="text" name="fname"/>
Last name :<input type="text" name="lname"/>
Email : <input type="text" name="email"/>
Address : <input type="text" name="address"/>
<input type="submit" value="SUBMIT"/>
</form>


sendmail.php
-------------


    $subject="test";//user subject

    $to = 'test1@yahoo.com' . ', '.'test2@yahoo.com'; // note the comma

    $fname=$_POST[fname];
        $lname=$_POST[lname];
    $address=$_POST[address];
    $from=$_POST[email]; //$user->email;

    $message = <<<MESSAGE
<html>
<body>
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="18%" valign="top"> FIRST NAME : </td>
    <td width="82%">$fname</td>
  </tr>
<tr>
    <td width="18%" valign="top"> LAST NAME : </td>
    <td width="82%">$lname</td>
  </tr>
<tr>
    <td valign="top">EMAIL : </td>
    <td>$from</td>
  </tr>
  <tr>
    <td valign="top">ADDRESS : </td>
    <td>$address</td>
  </tr>

    </table>
</body>
</html>
MESSAGE;


    $mail_mime .= "MIME-Version: 1.0\n";

       $mail_mime .= "Content-Type: text/html;\n";
      $mail_mime .= "Message-ID: <".md5($to)."@$_SERVER[SERVER_NAME]>\n";

    mail($to,$subject,$message,"Reply-to: $from\nFrom: $from\n".$mail_mime);

    echo "The mail was sent!";



i hope this help u... plz let me know if this is what u want....
Reply With Quote
  #3 (permalink)  
Old February 13th, 2007, 04:07 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks so much for your reply!

I have a php script that sends mail, but I don't know how to BOTH submit the data to my sql database and use a php email action like your "sendmail.php"

I want the form to both submit the data and then email the data submitted to a couple email addresses

I apologize if I am not explaining this well, I am new to php and mysql.

Thanks
Reply With Quote
  #4 (permalink)  
Old February 13th, 2007, 09:47 AM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh well in sendmail.php you can write mysql query to insert the record into database like mysql_query("insert into tablename(col1, col2, col3, col4,..) values ("$_POST[fname]","$_POST[lname]",...) u can write this code at the top of this sendmail.php page


let me know if it is this what u have been asking for...

Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding non-form data to an Insert chroniclemaster1 ASP.NET 2.0 Basics 5 February 17th, 2008 01:00 AM
Using a form field to direct an INSERT INTO SQL GusGray Access VBA 2 January 25th, 2008 09:50 AM
insert data in two tables from form mfarooqw ASP.NET 1.0 and 1.1 Professional 1 July 10th, 2007 08:34 AM
How to insert bulk of data through form in databas ashuphp Beginning PHP 1 April 11th, 2007 07:36 AM
INSERT Data to SQL Database Lofa ASP.NET 1.0 and 1.1 Basics 1 February 22nd, 2006 03:09 AM



All times are GMT -4. The time now is 12:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.