Jump to content

Yet another php form issue-


enzogfx

Recommended Posts

Please bear with me- its probably something simple
my problem is not being able to post additional fields in my email other than the $subject and $message-

So you know what im working with here is my form:
<form action="tech_form_process.php" method="post">
  <p>Name:
    <input type="text" name="name" size="30" maxlength="20" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Organization:
<input type="text" name="organization" size="30" maxlength="20" />
    <br />
    <br />
Phone : 
    <input type="text" name="phone" size="30" maxlength="30" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    Email : 
    <input type="text" name="email" size="30" maxlength="30" />
    <br />
    <br />
    Product Manufacturer:
    <input type="text" name="product manufacturer" size="30" maxlength="30" />
    Model Number
    :
    <input type="text" name="model number" size="30" maxlength="30" />
    <br />
    <br />
    Subject:
    <input type="text" name="subject" size="65" maxlength="30" />
  </p>
  <p>Please give as complete description of the problems you are having below: <br />
    <textarea name="problem" cols="80" rows="15"></textarea>
    <br />
    <input type="submit" name="submit" value="Send" />
  </p>
  <p>Please allow up to 24 hours for processing.<br />
One of our associates will contact you as soon as possible. </p>
</form>

============================
and here is my process

<?php
@extract($_POST);
$subject = stripslashes($subject);
$problem = stripslashes($problem);
$url = "index1.php";
mail('[email protected]',$subject,$problem);
header("location:$url");
?>

Anytime i add the other fields obviously the mail () doesnt work-  I thought it would be something like this
mail('[email protected]', $subject, $problem, $name, $phone, $organization....ect);

Obviously this is wrong- what would be the variable string i would input so that all my fields would be posted in my email?
Thanks in advanced-
Link to comment
https://forums.phpfreaks.com/topic/30246-yet-another-php-form-issue/
Share on other sites

The mail function only has 4 parameters
[code]mail($to,$subject,$message,$headers)[/code]

Your $to should be the e-mail address you are sending to. Obviously.
The $subject should be exactly that.
The $message should be your message in text or html format.
you can do something like this
[code]$message = "Problem with $Product_manufacturor\n\r";
$message .= "Model# $model_number\n\r";
$message .= "blah blah blah\n\r";[/code]
notice the \n\r at the end. in an e-mail message this is a new line or carriage return.

Now the $headers is something different. This has to have all the guidelines for your type of e-mail message.
This can be something like this
[code]$headers = "From: Johnny <your_email@your_domainl.com>\r\n";

//leave the next 2 lines alone for html message
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";[/code]

Now you can send the message correctly
Craygo-
Thanks for your help- All fields are submitting now and being posted in the email
The only thing not functioning is the new line break-
[quote]<?php
@extract($_POST);
$subject = stripslashes($subject);
$message = "$name with $organization is having a\n\r";
$message .= "Problem with $product_manufacturer\n\r";
$message .= "Model# $model_number\n\r";
$message .= "$problem\n\r";
$message .= "their contact info is $phone $email\n\r";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$url = "index1.php";
mail('[email protected]',$subject,$message,$headers);
header("location:$url");
?>[/quote]
Is there something still not right at the end?
OK sorry, since we have this sent as a html page just the $message part should be set up like a web page. So instead of \n\r you would use html code which would be
[code]<br>[/code]

Sorry for the mix up
[code]<?php
@extract($_POST);
$subject = stripslashes($subject);
$message = "$name with $organization is having a<br>";
$message .= "Problem with $product_manufacturer<br>";
$message .= "Model# $model_number<br>r";
$message .= "$problem<br>";
$message .= "their contact info is $phone $email<br>";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$url = "index1.php";
mail('[email protected]',$subject,$message,$headers);
header("location:$url");
?>[/code]

Ray

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.