Ampboy Posted May 16, 2014 Share Posted May 16, 2014 I have something that I cannot get to work.. The code I usually use uses INSERT and not UPDATE and has the user fill out all the fields. What I have now is a form where the user updates their PIN and email address. I have the update working. I just need to figure out how to get an email to the admin and to the end user based on where they are located Here is what I have: $dbhost = "localhost"; $dbname = "jimkoons_freshstart"; $dbuser = "jimkoons_start"; $dbpass = "Koons123"; $conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass); $sql = "Update Customers SET Email = :Email WHERE PIN = :PIN"; $stmt = $conn->prepare($sql); $stmt->bindValue(':PIN', $_POST['PIN'], PDO::PARAM_STR); $stmt->bindValue(':Email', $_POST['Email'], PDO::PARAM_STR); header("Location: http://koonsfreshstart.com/thank-you"); $stmt->execute(); Here is the snippet I use to email based on location in previous applications $STH->bindValue(':PIN', $_POST['PIN']); $STH->bindValue(':FirstName', $_POST['First']); $STH->bindValue(':LastName', $_POST['Last']); $STH->bindValue(':Email', $_POST['Email']); try { // Retrieve the user's name and associated list items $sql = "SELECT * FROM Customers WHERE PIN = PIN"; $stmt = $conn->prepare($sql); // Prepare the statement if($stmt->execute(array($_POST['PIN']))) { // Loop through the returned results while($row = $stmt->fetch()) { // Save the Store name $PIN = $row['PIN']; // Create an array of items $items[] = $row['PIN']; } $stmt->closeCursor(); // Free memory used in this query $first = $_POST["first"]; $last = $_POST["last"]; $email = $_POST["email"]; $PIN = $_POST['PIN']; switch ($PIN) { case "East": $to = "mail@mail.com"; $subject = "Mail"; $message = "$first $last Email Address: $email"; $user = "$email"; $usersubject = "Thank You for your submission"; $userheaders = "From: no-reply@mail.com\n"; $usermessage = "Thank you for submitting your information. We will be contacting you soon with more information on a customized extended service agreement for your vehicle. We look forward to working with you!"; mail($to,$subject,$message,$headers); mail($user,$usersubject,$usermessage,$userheaders); header("Location: http://mail.com/second/"); break; etc... Any help on making this work would be appreciated.. It is showing any errors, but it is not redirecting or emailing any of the data. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/288547-update-table-and-send-email/ Share on other sites More sharing options...
ginerjm Posted May 17, 2014 Share Posted May 17, 2014 Your code is hard to follow. But - if you turn on error checking you should get some help in finding your errors. ALWAYS TURN ON ERROR CHECKING DURING DEVELOPMENT. The first rule of developing in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/288547-update-table-and-send-email/#findComment-1479851 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.