Jump to content

email php form sending hosting Server info..


grk101

Recommended Posts

hey this is the code..

 

<?php
session_start();
   if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) {




// Receiving variables
@$ip= $_SERVER['REMOTE_ADDR'];

@$inqType = addslashes($_POST['inqType']);
@$where = addslashes($_POST['where']);
@$other = addslashes($_POST['other']);
@$name = addslashes($_POST['name']);
@$comments = addslashes($_POST['comments']);


// Validation
if (strlen($name) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>");
}

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}

if (strlen($email) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}

//Sending Email to form owner

$subject = "Contact";
$to = "test@test.com";
$message = "Visitor's IP: $ip\n"
. "name: $name\n"
. "phone: $phone\n"
. "email: $email\n"
. "comments: $comments\n";

@mail($to, $subject ,$message  ) ;

//Sending auto respond Email to visitor
$header = "From: test@test.com\n"
  . "Reply-To: test@test.com\n";
$subject = "tech support";
$email_to = "$email";
$message = "thanks";
@mail($email_to, $subject ,$message ,$header ) ;


//saving record in a text file
$file_name = "test.csv";
$first_raw = "inqType,where,other,name,comments\r\n";
$values = "$inqType,$where,$other,$name,".str_replace ("\r\n","<BR>",$comments )."\r\n";
$is_first_row = false;
if(!file_exists($file_name))
{
$is_first_row = true ;
}
if (!$handle = fopen($file_name, 'a+')) {
die("Cannot open file ($file_name)");
exit;
}
if ($is_first_row)
{
  if (fwrite($handle, $first_raw ) === FALSE) {
  die("Cannot write to file ($filename)");
  exit;
  }
}
if (fwrite($handle, $values) === FALSE) {
  die("Cannot write to file ($filename)");
  exit;
}
fclose($handle);


echo("<p align='center'><font face='Arial' size='2' color='#000000'>thank you</font></p>");
       unset($_SESSION['security_code']);
   } else {
           header( "Location: error.html" );

   }
?>

Link to comment
Share on other sites

You don't indicate which mail() function is not working.

 

Your first mail() function does not contain the extra header parameter so it will use the default settings in the php.ini for the From: address. Your second mail() function is using the extra header field, but is only using \n as the new line. Try using a specification \r\n to see if the header lines start being recognized.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.