Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to display name when message was sent ?

    I have created the simple contact form and doing some tweak. My question whenever the visitor sent the message, the line should be display "Thank you $name your form has been submitted". How can i write this on echo, I am doing this, but it was not taken. Here is my PHP code

    Code:
    <?php
      
      if (isset($_POST['contact_name']) && isset($_POST['contact_email']) && isset($_POST['contact_time']) && isset($_POST['contact_text'])) {
      		$contact_name = $_POST['contact_name'];
      		$contact_email = $_POST['contact_email'];
      		$contact_time = $_POST['contact_time'];
      		$contact_text = $_POST['contact_text'];
      		
      		
     		
     		if (!empty($contact_name) && !empty($contact_email) && !empty($contact_time) && !empty($contact_text)) {
     			$to = 'test@moneyrobot.in';
     			$subject = 'Custom Contact Form';
     			$body = $contact_name."\n".$contact_time."\n".$contact_text;
     			$headers ='From: '.$contact_email;
     			
     			if (mail($to, $subject, $body, $headers)) {
     				echo 'Your form has been submitted. We\'ll contact you shortly.';
     				} else {
     				echo 'There was an error';
     			}
     			
     		}else {
     			echo 'All fields are required.';
     		}
     }
     
     ?>

  • #2
    New Coder
    Join Date
    Nov 2011
    Location
    Ratio, Logic
    Posts
    60
    Thanks
    3
    Thanked 6 Times in 6 Posts
    Change this:
    PHP Code:
    'Your form has been submitted. We\'ll contact you shortly.'
    to this:
    PHP Code:
    "Thank you $contact_name your form has been submitted" 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •