WebFaction
Community site: login faq

I have some php files for sending email with fields inputed information. but when I get my email it is blank. Is there any other php script that needs to be added or any settings that need to be added?

asked 27 Sep '12, 17:34

ericspecullaas
1136
accept rate: 0%

What does your PHP code look like? I've got experience with this kind of problem so I might be able to help if I see what you're doing.

(27 Sep '12, 17:49) Zamphatta

im also using this "<input name="cname" type="text" value="&lt;?php echo htmlentities($cname) ?&gt;" size="40" &gt;"="" in="" the="" form="" and="" have="" made="" it="" regular="" values="" like="" "<input="" name="cname" type="text" value="" id="cname" size="40"> <?php $your_email ='email@email.com';

session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = '';

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

$name = $_POST['name'];
$visitor_email = $_POST['email'];
$user_message = $_POST['message'];
///------------Do Validations-------------
if(empty($name)||empty($visitor_email))
{
    $errors .= "\n Name and Email are required fields. ";   
}
if(IsInjected($visitor_email))
{
    $errors .= "\n Bad email value!";
}
if(empty($_SESSION['6_letters_code'] ) ||
  strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
    $errors .= "\n The captcha code does not match!";
}

if(empty($errors))
{
    //send the email
    $to = $your_email;
    $subject="Information Request Form";
    $from = $your_email;
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';

    $body = "A user $name submitted the following contact information:\n".
    "Company Name: $cname\n".
    "Name: $name\n".
    "Phone Number: $phone\n".
    "Email: $email \n".
    "Message: $user_message\n".
    "IP: $ip\n";

    $headers = "From: $from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";

    $retval = mail ($to, $subject, $body,$headers);

    if( $retval == true )

{ echo "

Message sent successfully...

"; } else { echo "

Message could not be sent...
"; } } }

// Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(n+)', '(r+)', '(t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } echo"<!doctype html>n"; ?> NOTE: 2 values work the name and the message but nothing else works

(27 Sep '12, 18:03) ericspecullaas

I notice your html shows a form field labeled 'cname', but no 'name'. In your php, you don't refer to these but use $_POST['name']. Is that the problem?

permanent link

answered 27 Sep '12, 18:23

Zamphatta
315
accept rate: 0%

no I do refer to them. I just didnt want to put the whole form on here.

(27 Sep '12, 18:37) ericspecullaas

here is the form if you insist <form method="POST" name="contact_form" action="&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;" &gt;="" <p=""> <label for="name">Company Name:</label>

<input name="cname" type="text" value="" id="&lt;?php echo htmlentities($cname) ?&gt;" size="40" &gt;="" <="" p="">

<label for="name">Name:</label>

<input name="name" type="text" value="&lt;?php echo htmlentities($name) ?&gt;" size="40" &gt;="" <="" p="">

<label for="name">Phone Number:</label>

<input name="phone" type="text" value="&lt;?php echo htmlentities($phone) ?&gt;" size="40" &gt;="" <="" p="">

<label for="email">Email:</label>

<input name="email" type="text" value="&lt;?php echo htmlentities($visitor_email) ?&gt;" size="40" &gt;="" <="" p="">

<label for="message" class="">Questions / Comments:</label>
<textarea name="message" rows="8" cols="40"> </form>

(27 Sep '12, 18:38) ericspecullaas

ok i figured it out i now have it working. beond simple fix if you read the code right.

permanent link

answered 27 Sep '12, 19:56

ericspecullaas
1136
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×262
×9

question asked: 27 Sep '12, 17:34

question was seen: 5,255 times

last updated: 27 Sep '12, 19:56

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM