Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PHP contact form not sending data to mysql database

I’m a brand new beginner in this… This is my PHP, I’ve got it working to send the email, however, I’m struggling to connect it to the database. I’d welcome any pointers at all! Thanks so much! 🙂

<?php
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'sendEmail')
{
    $to = 'test@test.co.uk';
    $subject = 'websitecontactform';
    $send_arr = array();    
    
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= "From: <".$_REQUEST['con_email'].">" . "\r\n";
    $headers .= "Cc: ".$_REQUEST['con_email'] . "\r\n";
    
    $message = "First Name : ".$_REQUEST['fname']. "<br />";
    $message .= "Last Name : ".$_REQUEST['lname']. "<br />";
    $message .= "Email : ".$_REQUEST['con_email']. "<br />";
    $message .= "Phone : ".$_REQUEST['con_phone']. "<br />";
    $message .= "Country : ".$_REQUEST['con_country']. "<br />";
    $message .= "Message : ".$_REQUEST['con_message']. "<br />";
    
    if (mail($to,$subject,$message,$headers) ){
        
        $send_arr['response'] = 'success';
        $send_arr['message'] = 'Your message has been sent.';
        
        } else{
            
        $send_arr['response'] = 'error';
        $send_arr['message'] = "You message couldn't be sent. Please try later!";
            
            }
    echo json_encode($send_arr);
    exit;
    
}

?>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

you must be clear with your question, i cant see any database query.

  • First connect to a database
  • Then write insert query to insert data.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading