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 8296863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:11:10+00:00 2026-06-08T15:11:10+00:00

I have a form where an user enters into a message, and the message

  • 0

I have a form where an user enters into a message, and the message gets sent to the recipient on the other end. I have tried this script multiple times, scoured tutorials, yet I can’t seem to find what’s wrong. Any ideas?

HTML Form:

 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
       <?php 
        if(isset($sent))
                 echo 'Your message has been sent. '; ?>
      <label for="Name">Name</label><br />                  
      <input type="text" class="textbox" size="35" id="Name" name="Name" <?php if(isset($name)) echo "value=\"$name\"";?> /><br />
      <label for="Service">Service</label><br />
      <input type="text" size="35" class="textbox" id="Service" name="Service" <?php  if(isset($subject)) echo"value=\"$subject\"";?> /><br />
      <label for="Email">Email</label><br />
      <input type="text" size="35" class="textbox" id="Email" name="Email" <?php if(isset($from)) echo"value=\"$from\""; ?> /><br />     
      <label for="message">Message</label><br />
      <textarea rows="95" cols="100" id="message" name="message"><?php if(isset($message)) echo"$message"; ?></textarea><br />
      <button type="submit">Send Message</button>               
</form>

PHP:

if(isset($_POST['Name']) && isset($_POST['Email']) && isset($_POST['Service']) && isset($_POST['message'])) {
    $name = $_POST['Name'];
    $from = $_POST['Email'];
    $subject = $_POST['Service'];
    $to = "emailtestertora@gmail.com";
    $message = $_POST['message'];
    mysql_query("INSERT INTO `Contact`(`Name`, `Email`, `Message`, `Service`) VALUES('$name', '$from', '$message', '$subject')");
    $headers = "From:".$from;
    if(mail($to,$subject,$message,$headers)) 
        $msgsent = true;
}

Thanks!

  • 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-08T15:11:13+00:00Added an answer on June 8, 2026 at 3:11 pm

    (Apologies as this should go as a comment, but it’ll be easier layed out in the textbox)

    Firstly, debug with the following code:

    <?php
    
    error_reporting(E_ALL);
    ini_set('display_errors', 'on');
    
    if (mail('emailtestertora@gmail.com', 'test', 'test')) {
        echo 'Mail Sent';
    } else {
        echo 'Mail Failed';
    }
    
    ?>
    

    This script will give you an error message when sending the e-mail that will help you debug.


    BUT, the important part of this comment, is that the e-mail script above is open to spam (as well as SQL injection). I would strongly encourage you to use a one of the functions/classes that are available that will help you cut out the security holes holes in your mail script.

    If you are determined to roll-your-own then great, but please read up about e-mail spam header injection before letting this script on a server. Spammers can send thousands of e-mails very quickly when they find an open script like this, they regularly test automatically so you must clamp down.

    (And read up about PHP Database object – PDO – at the same time to save the MySQL injection.)

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

Sidebar

Related Questions

I have a form on a webpage. When the user enters input into form,
I have a form that allows me to enter a user into my database.
I have a form, user enters some data then submits. Rather than a popup
I have a jsp form validate.jsp which contains 2 text fields where user enters
I have a PHP form that enters data into my MySQL database. My primary
I have this form where a user can input tags (tag_list input) like Graphic
I have a data entry form where user enters lots of data. When user
I have a form with a number of text boxes for user input (this
In this scenario: User enters some information into a textbox User clicks a button
in my application i have an form where user enter their username first .

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.