Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2007, 10:30 PM
Registered User
 
Join Date: Jan 2007
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
 
Old February 13th, 2007, 03:17 AM
Authorized User
 
Join Date: Feb 2007
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 = '[email protected]' . ', '.'[email protected]'; // 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....
 
Old February 13th, 2007, 04:07 AM
Registered User
 
Join Date: Jan 2007
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
 
Old February 13th, 2007, 09:47 AM
Authorized User
 
Join Date: Feb 2007
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...






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.