Jump to content

Recommended Posts

Below is my php file from my website srcfresno.com/inquiry2.htm

 

When I go to the website and enter information in the form fields, it submits to my email fine but the email I receive has no information filled in. Please help. Not sure why

 

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Statistics & Research Consulting</title>

</head>

<?php

$to = 'inquiry@srcfresno.com';

$subject = 'Contact Inquiry form';

$firstname = $_REQUEST['First Name'] ;

$lastname = $_REQUEST['Last Name'] ;

$from = $_REQUEST['Email'] ;

$phone = $_REQUEST['Phone'] ;

$company = $_REQUEST['Company Website (if applicable)'] ;

$messege = $_REQUEST['Please describe your interest in Statistics & Research Consulting'] ;

 

$fields = array(

'firstname' => 'First Name',

'lastname' => 'Last Name',

'from' => 'Email',

'phone' => 'Phone',

'company' => 'Company Website (if applicable)',

'message' => 'Please describe your interest in Statistics & Research Consulting'

);

 

$body = "We have received the following information from $_SESSION[username]:\n\n";

foreach($_REQUEST as $a => $b){

if(array_key_exists($a, $fields) && !empty($b)){

  $part1 .= sprintf("%20s: %s\n", $fields[$a], $b);

}

 

$send = mail($to, $subject, $body);

 

if($send)

{print "Thank you for contacting us. We have received your information and a SRC Consultant will respond shortly."; }

else

{print "We encountered an error sending your mail, please notify webmaster@srcfresno.com"; }

 

?>

 

<body>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/245542-php-fields-array-help/
Share on other sites

This is the correct php code

 

<?php 
$to = 'inquiry@srcfresno.com';
$subject = 'Contact Inquiry form'; 
$firstname = $_REQUEST['First Name'] ;
$lastname = $_REQUEST['Last Name'] ;
$from = $_REQUEST['Email'] ;
$phone = $_REQUEST['Phone'] ; 
$company = $_REQUEST['Company Website (if applicable)'] ;
$messege = $_REQUEST['Please describe your interest in Statistics & Research Consulting'] ;
  
$fields = array( 
'firstname' => 'First Name',
'lastname' => 'Last Name',
'from' => 'Email',
'phone' => 'Phone',
'company' => 'Company Website (if applicable)',
'message' => 'Please describe your interest in Statistics & Research Consulting'
); 

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ 	$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
  
$send = mail($to, $subject, $body); 

if($send)
{print "Thank you for contacting us. We have received your information and a SRC Consultant will respond shortly."; } 
else 
{print "We encountered an error sending your mail, please notify webmaster@srcfresno.com"; }

?> 


<body><form action="contact.php" method="post" enctype="multipart/form-data" name="input" target=_blank>
    <h2><span class="style14">Contact Inquiry Form </span></h2>
    <p> </p>
    <p>
      <span class="style24 style2">Customer Name</span>
      <br>
      <input name="textfield" type="text" size="50">
    First Name<br>
    <br>
    <input name="textfield" type="text" size="50">
  Last Name</br>
    </p>
    <p>
      <span class="style24 style2">Email</span><br>
  <input name="textfield" type="text" size="50">
  </br> </p>
    <p>      <span class="style24 style2">Phone</span>
  <br>
  <input name="textfield" type="text" size="50">
  </br> </p>
<p>
  <span class="style24 style2">Company Website (if applicable)</span>
  <br>
  <input name="textfield" type="text" size="50">
  </br> </p>
<p>
  <span class="style24 style2">Please describe your interest in Statistics & Research Consulting</span>  
      <br>
      <textarea name="textarea" cols="50" rows="10"></textarea>
  </br></p> 
    <p>
      <input type="submit" name="Submit" value="Submit">
  </p>
  </form>

Try

 

Form

<body><form action="contact.php" method="post"  name="input" target=_blank>
    <h2><span class="style14">Contact Inquiry Form </span></h2>
    <p> </p>
    <p>
      <span class="style24 style2">Customer Name</span>
      <br>
      <input name="firstname" type="text" size="50">
    First Name<br>
    <br>
    <input name="lastname" type="text" size="50">
  Last Name</br>
    </p>
    <p>
      <span class="style24 style2">Email</span><br>
  <input name="email" type="text" size="50">
  </br> </p>
    <p>      <span class="style24 style2">Phone</span>
  <br>
  <input name="phone" type="text" size="50">
  </br> </p>
<p>
  <span class="style24 style2">Company Website (if applicable)</span>
  <br>
  <input name="company" type="text" size="50">
  </br> </p>
<p>
  <span class="style24 style2">Please describe your interest in Statistics & Research Consulting</span>  
      <br>
      <textarea name="message" cols="50" rows="10"></textarea>
  </br></p> 
    <p>
      <input type="submit" name="Submit" value="Submit">
  </p>
  </form>

 

contact

<?php 
$to = 'inquiry@srcfresno.com';
$subject = 'Contact Inquiry form'; 
if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); }
  
$fields = array( 
'firstname' => 'First Name',
'lastname' => 'Last Name',
'email' => 'Email',
'phone' => 'Phone',
'company' => 'Company Website (if applicable)',
'message' => 'Please describe your interest in Statistics & Research Consulting'
); 

$body = "We have received the following information:\n\n"; 
foreach($fields as $a => $b) { 	
if(array_key_exists($a,$_POST)) {
	$body .= sprintf("%s: %s\n",$b,$_POST[$a]);
}
}
  
$send = mail($to, $subject, $body); 

if($send)
{print "Thank you for contacting us. We have received your information and a SRC Consultant will respond shortly."; } 
else 
{print "We encountered an error sending your mail, please notify webmaster@srcfresno.com"; }

?> 

 

Let us know how it goes.

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.