Jump to content

PHP eMail form HELP PLEASE!!


Onzeon

Recommended Posts

Hello my great PHP gurus, I have a question that might be simple for some of you geniuses. I have simple HTML email form getting sent by a PHP script and I cant get it to work right.

All I want is the get the email, name, subject and in the body I need to have 3 variables ( name (again) Telephone and details. This is the code I have so far:

 

HTML Form (relevant details only):

 

<input type="text" name="name" id="name" class="input" />

<input type="text" name="subject" id="subject" class="input" />

<input type="text" name="email" id="customer_mail" class="input" />

<input type="text" name="telephone" id="telephone" class="input" />

<textarea name="detail" cols="10" rows="10" id="detail"></textarea>

 

The PHP script is:

 

<?php

// Contact subject

$subject ="$subject";

// Details

$message="$detail";

// Name

$name="$name";

 

// Mail of sender

$mail_from="$customer_mail";

// From

$header="from: $name <$mail_from>";

 

// Enter your email address

$to ='onzeon@me.com';

 

$send_contact=mail($to,$subject,$message,$header);

 

// Check, if message sent to your email

// display message "We've recived your information"

if($send_contact){

echo "We received you message, thank you";

}

else {

echo "ERRO";

}

?>

 

I also tried this (with no success):

 

<?php

// Contact subject

$subject ="$assunto";

 

// Details

$body = $name;

$body .= "/n";

$body .= "Telephone : ".$telephone."/n";

$body .= "Subject : ".$subject."/n";

$body .= "Details : ".$details;

 

// Name

$name="$name";

 

// Mail of sender

$mail_from="$customer_mail";

// From

$header="from: $name <$mail_from>";

 

// Enter your email address

$to ='onzeon@me.com';

 

$send_contact=mail($to,$subject,$header,$body);

 

// Check, if message sent to your email

// display message "We've recived your information"

if($send_contact){

echo "We received you message, thank you";

}

else {

echo "ERRO";

}

?>

 

CAN ANYONE HELP, PLEASE..

Thank you very much.

 

Cleve.

Link to comment
Share on other sites

Thank you for your reply. (wow)

I apologize if I'm not very good in the PHP lingo.

I dont get any errors. It goes through, but all I get in the email is

The name (where the email should be)

The Subject is correct. :)

The the body gets the details but nothing else.

 

I want to get The email where the email should be.

The subject is fine.

and in the body is where I really need help.

I want the have this body:

 

Name: (the $name ID)

Telephone: (the $telephone ID)

Subject: (the $subject ID)

 

I know my PHP is probably all wrong.

Please help if you can, I've been trying for a while to get it right. :)

Thank you.

Link to comment
Share on other sites

From the code that you posted, you need to read up a bit on the use of $_POST variables

html form relevent details include form method and action as well by the way.

 

what you should have is

$name = $_POST['name'];
$message = $_POST['detail'];
$subject = $_POST['subject'];

etc.

For all the variables that you are taking from the form (assuming that you have method="POST" in your form decleration). - also, it is the elements name that you will link to, not the id.

 

change that in your code and let us know how it goes.

Link to comment
Share on other sites

Maybe I'm going about this the wrong way, I should ask you PHP gurus a tutorial on how to build the script I'm trying to build. I've been at this for days, and the more I read the more confusing it gets. What I want to achieve is: I have a XHTML form with 5 user input fields - These are:

 

name

subject

cust_email

telephone

details

 

I need to create a PHP script that will on user click - submit a email that has this format:

 

From= cust_email

 

Subject= "Customer requested information on" +subject

 

eMail body= name + "requests information on" + subject

/n

+ details

/n

+ "Contact information"

/n

+telephone

+email.

 

So the body would look some how like this:

 

Jane Smith requests information on Botox

 

Hello I'm interested in botox injections please contact me with pricing and availability. Thank you.

 

Contact information.

(888)555-1212

Jsmith@hotmail.com

 

Can you or anyone of the users in this wonderful forum HELP. I'm a print designer and I can assist you guys with anything you may need in print. But web is all to new and I'm struggling.

Thank you, thank you very much.

 

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.