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

  • Home
  • SEARCH
  • 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 7628329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:34:49+00:00 2026-05-31T05:34:49+00:00

Hey I have this code that sends an email with some data sent by

  • 0

Hey I have this code that sends an email with some data sent by a form:

<?php

  if (isset($_POST['submit'])) {

    error_reporting(E_NOTICE);

    function valid_email ($str) {
      return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
    }

    if ($_POST['name'] != '' &&  $_POST['email'] != '' && $_POST['tel'] != '' && valid_email($_POST['email']) == TRUE && strlen($_POST['comment']) > 1) {

      $to = preg_replace("([\r\n])", "", $_POST['receiver']);
      $from = preg_replace("([\r\n])", "", $_POST['name']);
      $subject = 'Online Message';
      $message = $_POST['comment'];
      $match = "/(bcc:|cc:|content\-type:)/i";
      if (preg_match($match, $to) || preg_match($match, $from) || preg_match($match, $message) || preg_match($match, $subject)) {
        die("Header injection detected.");
      }

      $headers = "From: \"".$_POST['name']."\" <".$_POST['email'].">\n";
      $headers .= "Reply-to: ".$_POST['email']."\r\n";

      if (mail($to, $subject, $message, $headers)) {
        echo 1; //SUCCESS
      } else {
        echo 2; //FAILURE - server failure
      }

    } else {
      echo 3; //FAILURE - not valid email
    }

  } else {
    die("Direct access not allowed!");
  }

I want to add the $_POST['tel'] to the $message variable so in the body of the email I can get the message plus the telephone that people type into the form. In the first part of the code I think I made the telephone input obligatory.

I tried doing $message = $_POST['comment'] && $_POST['tel']; but the only thing I recieve is a 1 in the body of the mail that is the first number of the telephone entered.

  • 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-05-31T05:34:50+00:00Added an answer on May 31, 2026 at 5:34 am

    $message = 'Comment: ' . $_POST['comment'] . ' Tel: ' . $_POST['tel'];

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

Sidebar

Related Questions

I have a code that sends POST data to a PHP website. Code: request
Hey, I have some text that is formatted like this: [quote]foo text[/quote] and I
Hey guys, I have this quick bit of code that I can't figure out
Hey guys, I have some code that I found that I would rather use
hey, I have this code that should save a java.util.Vector of custom serializable classes:
Hey guys, I have this code within a function inside a class that is
hey there i have this code that should save a file from sql server
hey there guys and girls i have this code that saves json as a
hey there guys and girls i have this code that should download a json
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get

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.