Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:19:57+00:00 2026-06-17T10:19:57+00:00

Someone please help me with my code everything seems to be fine but, when

  • 0

Someone please help me with my code everything seems to be fine but, when ever I click the Submit button the browser displays the PHP scripts instead of Sending the email to my mail account. PHP is installed I thought that was the problem. please help?????? here is my PHP script

                     <?php
    if(isset($_POST['submit'])) {


     $email_to = "example@domain.com";
    $email_subject = "Wedding Wishes";


     function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you";
    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['txtName']) ||
    !isset($_POST['txtSurname']) ||
    !isset($_POST['txtEmail']) ||
    !isset($_POST['txtRegion']) ||
    !isset($_POST['cmbRelation']) ||
    !isset($_POST['txtMessage'])) {
    died('We are sorry, but there appears to be a problem with the form you');                  
 }

$first_name = $_POST['txtName']; // required
$last_name = $_POST['txtSurname']; // required
$email_from = $_POST['txtEmail']; // required
$region = $_POST['txtRegion']; 
$relation = $_POST['txtRelation'];// not required
$message = $_POST['txtMessage']; // 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 Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
 }
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($message) < 2) {
$error_message .= 'The Comments you entered do 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 .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Region: ".clean_string($region)."\n";
$email_message .= "Relation: ".clean_string($relation)."\n";
$email_message .= "Message: ".clean_string($message)."\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);  
    ?> 

And my Html form is as follows.

 <div class="grid_16" style="width:400px;">
  <div class="top-1">
  <form id="form" method="post" action="SendEmail_Wishes.php" style="width: 400px;" >
  <fieldset>
    <p>
      <label><strong>Name:</strong>
        <input type="text" name="txtName" style= "width:300px; height:25px;">
        <strong class="clear"></strong></label>
      <label><strong>Surname:</strong>
        <input type="text" name="txtSurname" style= "width:300px; height:25px;">       
        <strong class="clear"></strong></label>
      <label><strong>Email:</strong>
         <input name="txtEmail" type="text" style= "width:300px; height:25px;">
        <strong class="clear"></strong></label>
      <label><strong>Region:</strong>
        <input name="txtRegion" type="text" id="txtRegion" value="Country & City"  >
        <strong class="clear"></strong></label>
      <label><strong>Relation:</strong>
        <select name="cmbRelation" id="cmbRelation" accesskey="2" tabindex="2">
          <option value="Family">Family</option>
          <option value="Friend" selected>Friend</option>
        </select>
         <br>
       </label>
       <label><strong>Message:</strong>
        <textarea name="txtMessage" id="txtMessage"  style= "width:300px;"></textarea>  
<font size="1"><br />
<br />
<br />
<br />
<br />
<br />
(Maximum characters: 250)<br>
<input name="submit" type="submit" value="submit" style="width:50px;">



<br />
      <strong class="clear"></strong></label>
    </p>

    <script type="text/javascript">
function blank(a) { if(a.value == a.defaultValue) a.value = ""; }
function unblank(a) { if(a.value == "") a.value = a.defaultValue; }
</script> 

<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
    limitField.value = limitField.value.substring(0, limitNum);
} else {
    limitCount.value = limitNum - limitField.value.length;
}
}
</script>



  </fieldset>
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:19:58+00:00Added an answer on June 17, 2026 at 10:19 am

    You don’t close the if(isset($_POST['submit'])) statement.

    You are missing } at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please help me with the code for below requirement or scenarios...I achieved
Please can someone help? I have the following code which uploads a file to
Can someone please help. I have been searching and encountered/modified this code I am
Could someone please help me to understand why the following block of code keeps
Someone please help. I have an interesting issue. I am trying to implement an
Can someone please help to clarify? Also, please mention if there are other representation
Could someone please help me to convert this String into a Map ... String
can someone please help me out? I'm trying to create an input dynamically with
Can someone please help quickly mute or unmute the stage volume in Flash CS3
can someone please help me. why does this return an error: Dim stuff As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.