quickfire84 Posted May 10, 2009 Share Posted May 10, 2009 Ok, i figured out how to post data in my DB and email it to me and submitter it works, but i get a error.. also some of the stuff like phone, anythingelse and idealcustomer does not submit... ?? <?php // Pick up the form data and assign it to variables $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $companyname = $_POST['companyname']; $idealcustomer = $_POST['idealcustomer']; $productservices = $_POST['productservices']; $maincompet = $_POST['maincompet']; $differcompet = $_POST['differcompet']; $needdone = $_POST['needdone']; $lookingfor = $_POST['lookingfor']; $doneby = $_POST['doneby']; $anythingelse = $_POST['anythingelse']; // Validation if($name == '') { die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid Name</font></p>"); } if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email)) { die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>"); } if($companyname == '') { die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid Company name</font></p>"); } //MySQL DATA INSERT TAGS START HERE $con = mysql_connect("localhost","moppiei1_chris1","zxcv2470"); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("moppiei1_customers", $con); //Replace with your MySQL DB Name $name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']);//This value has to be the same as in the HTML form file $phone=mysql_real_escape_string($_POST['phone']); $companyname=mysql_real_escape_string($_POST['companyname']); $idealcustomer=mysql_real_escape_string($_POST['idealcustomer']); $productservices=mysql_real_escape_string($_POST['productservices']); $maincompet=mysql_real_escape_string($_POST['maincompet']); $differcompet=mysql_real_escape_string($_POST['differcompet']); $needdone=mysql_real_escape_string($_POST['needdone']); $lookingfor=mysql_real_escape_string($_POST['lookingfor']); $doneby=mysql_real_escape_string($_POST['doneby']); $anythingelse=mysql_real_escape_string($_POST['anythingelse']); $sql="INSERT INTO quote (name,email,phone,companyname,idealcustomer,productservices,maincompet,differcompet,needdone,lookingfor,doneby,anythingelse) VALUES ('$name','$email','$phone','$companyname','$idealcustomer','$productservices','$maincompet','$differcompet','$needdone','$lookingfor','$doneby','$anythignelse')"; /*form_data is the name of the MySQL table where the form data will be saved.*/ if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "The form data was successfully added to your database."; mysql_close($con); //MySQL DATA INSERT TAGS END HERE // Build the email (replace the address in the $to section with your own) $to = '[email protected]'; $subject = "Quote Submittion"; $message = "Name: $name, \n Email: $email, \n Phone Number: $phone, \n Comapny Name: $companyname, \n Ideal Customer: $idealcustomer, \n Product or Services: $productservices, \n Main Competition: $maincompet, \n How You Differ From Competition: $differcompet, \n Services Needed: $needdone, \n Looking For: $lookingfor, \n Need Done By: $doneby, \n Anything Else: $anythingelse"; $headers = "From: $email"; // Send the mail using PHPs mail() function mail($to, $subject, $message, $headers); //Sending auto respond Email to visitor $header = "From: [email protected]" . "Reply-To: [email protected]"; $subject = "Confirmation of quote enquiry to moppie.illusions"; $to = "$email"; $message = "Thank You $n for choosing moppie.illusions, Your quote enquiry will be processed immediately \n \n \n Sincerely, \n Chris Cardarello \n Webmaster \n moppie.illusions "; // Send the mail using PHPs mail() function mail($to, $subject, $message, $headers); // Redirect header("Location: success.html"); ?> How can i get it to still goto my redirect also this is error i get The form data was successfully added to your database. Warning: Cannot modify header information - headers already sent by (output started at /home/moppiei1/public something about line 90.. Quote Link to comment https://forums.phpfreaks.com/topic/157596-help-with-script/ Share on other sites More sharing options...
ohdang888 Posted May 10, 2009 Share Posted May 10, 2009 The form data was successfully added to your database. Warning: Cannot modify header information - headers already sent by (output started at /home/moppiei1/public something about line 90.. you cannot echo anything before a header() function as for information missing, check that "name" on the inputs in your form match up with the name in the "POST" array for the ones that are missing. Quote Link to comment https://forums.phpfreaks.com/topic/157596-help-with-script/#findComment-831011 Share on other sites More sharing options...
quickfire84 Posted May 10, 2009 Author Share Posted May 10, 2009 Ok now with php how would i pull data from several tables by the ID. main table has a ID set primary key all other tables have the cutomerID as foreign keys set to the ID, so if i wanted to pull data from every table by the ID how would i do so using php??? Quote Link to comment https://forums.phpfreaks.com/topic/157596-help-with-script/#findComment-831019 Share on other sites More sharing options...
ohdang888 Posted May 10, 2009 Share Posted May 10, 2009 with a SELECT statement. google this: mysql select tutorial Quote Link to comment https://forums.phpfreaks.com/topic/157596-help-with-script/#findComment-831020 Share on other sites More sharing options...
GingerRobot Posted May 10, 2009 Share Posted May 10, 2009 Ok now with php how would i pull data from several tables by the ID. main table has a ID set primary key all other tables have the cutomerID as foreign keys set to the ID, so if i wanted to pull data from every table by the ID how would i do so using php??? You'd be looking to use a join. I'd suggest checking out this excellent tutorial: http://www.phpfreaks.com/tutorial/data-joins-unions Quote Link to comment https://forums.phpfreaks.com/topic/157596-help-with-script/#findComment-831036 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.