I am not familiar with PHP. I found a php form emailer from http://www.freecontactform.com/email_form.php and edited the .php file to match my html by changing the name elements.

I already fixed the syntax error with line 38 by removing the +$/" from:

$string_exp = "/^[A-Za-z .'-]+$/";

I tried to resubmit the form, again and came up with this error:
Parse error: syntax error, unexpected T_STRING in D:\Hosting\7000100\html\gmsngrqst.php on line 51

... this corresponds with the line:

$email_message = "Form details below.\n\n";

the surrounding coding is:

if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

I would appreciate any help on this issue as I am unsure of how to even search for an answer online for this error.

Is died a typo perhaps ?

died is a function in the class, i can only think of retyping the line and a couple before it and try changing \n\n to \r\n - can't see anything wrong otherwise

and don't want to insult you're intelligence but gmsngrqst.php is the right file?

Apparently the problem is elsewhere in the file :/ Yes, the file is titled "gmsngrqst.php" (General Manager Song Request, so that only I know what to look for, helps slightly with spam). Here is the entire file... personal information removed. Also, I tried to submit the form without a "/" sign in the Song Title (named "title") and it accepted the form, but I never received ANYTHING in my email (also, the redirect as specified in the actual form, did not redirect). As I am not familiar with PHP, is the $mail_to a correct function as it is defined within the PHP file??

<?php
if(isset($_POST['email'])) {
     
    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = array("email_removed","email_removed");
    $email_subject = "subject_removed";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['name']) ||
        !isset($_POST['location']) ||
        !isset($_POST['email']) ||
        !isset($_POST['artist']) ||
        !isset($_POST['title'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }
     
    $name = $_POST['name']; // required
    $location = $_POST['location']; // not required
    $email_from = $_POST['email']; // required
    $artist = $_POST['artist']; // required
    $title = $_POST['title']; // required
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$name)) {
    $error_message .= 'The name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$artist)) {
    $error_message .= 'The artist name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$title)) {
    $error_message .= 'The song name you entered does not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "Name: ".clean_string($name)."\n";
    $email_message .= "Location: ".clean_string($location)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Artist: ".clean_string($artist)."\n";
    $email_message .= "Song: ".clean_string($title)."\n";
     
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>
 
<!-- include your own success html here -->
 
Thank you for your request!
 
<?php
}
?>

I will try changing the \n\n with \r\n and see if it make a difference. A big thank you to BOTH of you for your help!

take off the @ infront of mail, @ suppresses errors

@mail($email_to, $email_subject, $email_message, $headers);

mail($email_to, $email_subject, $email_message, $headers);

it could be the server's mail settings such as requiring authentication when sending from a none local address - it's a good idea to make the email from a fixed local account on the server

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.