login community 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 Sep 27 '12 at 17:34

ericspecullaas's gravatar image

ericspecullaas
11

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.

(Sep 27 '12 at 17:49) Zamphatta Zamphatta's gravatar image

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'])) {

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$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

(Sep 27 '12 at 18:03) ericspecullaas ericspecullaas's gravatar image

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?

answered Sep 27 '12 at 18:23

Zamphatta's gravatar image

Zamphatta
33

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

(Sep 27 '12 at 18:37) ericspecullaas ericspecullaas's gravatar image

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>

(Sep 27 '12 at 18:38) ericspecullaas ericspecullaas's gravatar image

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

answered Sep 27 '12 at 19:56

ericspecullaas's gravatar image

ericspecullaas
11

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
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

Tags:

×146
×145
×7

Asked: Sep 27 '12 at 17:34

Seen: 406 times

Last updated: Sep 27 '12 at 19:56

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited