View Full Version : Insert info and email
rhamej
May 21st, 2005, 02:55 PM
Hey guys, need help agian with php.
I've created 6 different html contact forms that collect info and will store that info into a mySql db so the results can be searched later. This is not problem however. Each of those 6 forms will need the information sent to a different dept email address. Im stumped as to how to send the email AND send the info to the db at the same time. Seems like when I get one working the other one breaks. :(
This is the insert.php that Im using which works fine
<?
include("dbinfo.php");
$name=$_POST['name'];
$company=$_POST['company'];
$title=$_POST['title'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$state=$_POST['state'];
$contact_how=$_POST['contact_how'];
$message=$_POST['message'];
$query = "INSERT INTO contacts VALUES ('','$name','$company','$title','$email','$phone', '$state','$contact_how','$message')";
mysql_query($query);
mysql_close();
?>
I need this to send an email and to direct to a confirmation page. I can pay some one a little money like 50$ via paypal. It would only take a good coder like 15 minutes to do ;) May also need your services later down the line for developing the search form too. (thats if I cant figure it out) :P
Thanks,
Josh
abcdefg
May 21st, 2005, 03:43 PM
I wish I had time to do it for ya (for free of course) but I'm busy.
SO instead here's what I use on my pricequote system.
<?php
/////////////////////////////////////////////
// define all variables /////////////////////
/////////////////////////////////////////////
$quoteName = $_POST['strName'];
$quoteEmail = $_POST['strEmail'];
$quotePhone = $_POST['strPhone'];
$quoteCurrSite = $_POST['strCurrSite'];
$quoteSite01 = $_POST['strSite01'];
$quoteSite02 = $_POST['strSite02'];
$quoteDeadLine = $_POST['strDeadLine'];
$quoteBudget = $_POST['strBudget'];
$quoteLocation = $_POST['strLocation'];
$quotePageNum = $_POST['strPageNum'];
$quoteAdd = $_POST['strAdd'];
$quoteIPAdd = $_SERVER['REMOTE_ADDR'];
$quoteDate = date("F j, Y, g:i a");
$quoteElements = $_POST['elements'];
// send to me
$toEmail = "digitalosophy@gmail.com";
// who's it from
$fromEmail = $userEmail;
// the subject
$subject = "Digitalosophy Price Quote";
// body of the email
$body = "The following details were sent:\n\nSenders Name: $quoteName\nSenders Email: $quoteEmail\nSenders Phone Number: $quotePhone\nSenders Current Website: $quoteWebsite\nSenders Site They Like: $quoteSite01\nSenders Site They Like: $quoteSite02\nSenders Deadline: $quoteDeadLine\nSenders Budget: $quoteBudget\nSenders Job Location: $quoteLocation\nSenders Page Number: $quotePageNum\nSenders Additional Comments: $quoteAdd\nSenders Elements: $quoteElements\n\n";
// contents of the footer
$footer=".................................................. ..........\nMessage was sent by: $strName\nfrom IP Address $quoteIPAdd";
// concoctinate body and footer
$message = $body.$footer;
/////////////////////////////////////////////
// end variable definition //////////////////
/////////////////////////////////////////////
// send the mail
mail($toEmail,$subject, $message, "From: ".$quoteName." <".$quoteEmail.">");
/////////////////////////////////////////////
// database intergration ////////////////////
/////////////////////////////////////////////
// connect to database
$connect = mysql_connect("localhost", "", "");
// select the database
mysql_select_db ("", $connect);
// insert the data
$query = mysql_query("INSERT INTO quotes (quoteName, quoteEmail, quotePhone, quoteCurrSite, quoteSite01, quoteSite02, quoteDeadLine, quoteBudget, quoteLocation, quotePageNum, quoteAdd, quoteIPAdd, quoteDate) values ('$quoteName', '$quoteEmail', '$quotePhone', '$quoteCurrSite', '$quoteSite01', '$quoteSite02', '$quoteDeadLine', '$quoteBudget', '$quoteLocation', '$quotePageNum', '$quoteAdd', '$quoteIPAdd', '$quoteDate')");
if($query){
echo "writing=Ok&";
}else {
echo "writing=Error";
}
/////////////////////////////////////////////
// end database intergration ////////////////
/////////////////////////////////////////////
?>
You obviously don't need all those variables but I'm sure you bell able to figure it out with this
rhamej
May 21st, 2005, 03:47 PM
Thanks! Thats pretty much what I was doing. But after looking at yours I see what I did wrong. You rock! :D
abcdefg
May 21st, 2005, 03:59 PM
Anytime bro.
If you need help with the search feature I'll be on tomorrow around 3pm eastern hit me up on aim.
rhamej
May 21st, 2005, 06:30 PM
wooohooo! It's works like a charm :D
I may take you up on the search help. But I won't be touching the pc that much tomorrow. Im gonna be riding my downhill bike hoping I dont die :lol:
If I need help I will post here.
Thanks again Digital! :)
abcdefg
May 22nd, 2005, 03:56 PM
wooohooo! It's works like a charm :D
I may take you up on the search help. But I won't be touching the pc that much tomorrow. Im gonna be riding my downhill bike hoping I dont die :lol:
If I need help I will post here.
Thanks again Digital! :)
haha cool.
i'm from brooklyn new york but i just moved to staten island.
:kommie:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.