php/html form submission to email trouble

I’m trying to have this user input form submitted to my email from the website. I’ve been told i need php to do this and so I’ve been looking at various codes. I will include the HTML form code as well as the PHP code below. Any help will be greatly appreciated! Please email me with any help or solutions!
Thank you!

[php]

<?php $Client_name = $_POST['name']; $Client_Phone = $_POST['phone']; $Client_email = $_POST['email']; $Type_of_Computer = $_POST['type of computer']; $Brand = $_POST['brand']; $Model = $_POST['model']; $Operating_Sytem = $_POST['OS']; $Errors_and_Issues = $_POST['Errors']; $email_from = '[email protected]'; $email_subject = "Client Form submission"; $email_body = "You have received a new message from the user $Client_name.\n". "Here is the message:\n $Client_name, $Client_Phone, $Client_email, $Type_of_Computer, $Brand, $Model, $Operating_System, $Errors_and_Issues". $to = "[email protected], [email protected]"; $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to,$email_subject,$email_body); ?>

[/php]

<html>
<body>
<form method="post" action="http://www.lfpctech.net/thanks/">
<p>Fields with * are required.</p>
<fieldset><legend>Client Information</legend>
<div class="field-item"><label>Name: *</label> <input maxlength="150" size="30" id="Client_Name" name="Client_Name" type="text" title="" /><br /></div>
<div class="field-item">
<div><label>Phone: *</label> <input maxlength="20" size="20" id="Client_phone" name="Client_phone" type="text" title="" />
<p class="small">(555) 555-0000</p>
</div>
</div>
<div class="field-item">
<div><label>E-mail Address: *</label> <input class="" maxlength="30" size="20" id="Client_Email" name="Client_Email" type="text" /></div>
</div>
</fieldset>
<fieldset><legend>Computer Information</legend>
<div class="field-item">
<div>
<p>Type of Computer: *<select name="Type" size="1">
<option>Desktop/Tower</option>
<option>Laptop</option>
<option>Netbook</option>
<option>Custom</option>
</select></p>
</div>
<div class="field-item">
<div>
<p>Brand: *<select name="type" size="1">
<option>Acer</option>
<option>Asus</option>
<option>Compaq</option>
<option>Dell</option>
<option>Emachines</option>
<option>Gateway</option>
<option>HP</option>
<option>Lenovo</option>
<option>Sony</option>
<option>Toshiba</option>
<option>Custom</option>
</select><br /></p>
<div class="field-item">
<div><label>Model Number:</label> <input type="text" name="mnumber" /></div>
</div>
<div class="field-item">
<div>
<p>Operating System: *<select name="type" size="1">
<option>Windows XP</option>
<option>Windows Vista</option>
<option>Windows 7</option>
</select></p>
</div>
</div>
</div>
</div>
</div>
</fieldset>
<fieldset><legend>Errors and Issues</legend>
<div class="field-item">
<div>
<p>Tell us what errors or issues you are experiencing, please try to include any error messages as best as possible *</p>
<textarea rows="10" cols="100">
</textarea>
<br />
<br />
<input type="submit" value="Send" /> <input type="reset" value="Reset" /></div>
</div>
</fieldset>
</form>
</body>
</html>
Hello Lucien, i found that you are not using proper html form for collecting clients information. use below script. save and run this script. [php] <? if($REQUEST_METHOD == 'POST') { $Client_name = $_POST['Client_Name']; $Client_Phone = $_POST['Client_phone']; $Client_email = $_POST['Client_Email']; $Type_of_Computer = $_POST['toc']; $Brand = $_POST['brand']; $Model = $_POST['mnumber']; $Operating_Sytem = $_POST['os']; $Errors_and_Issues = $_POST['error']; $email_from = '[email protected]'; $email_subject = "Client Form submission"; $email_body = "You have received a new message from the user ".$Client_name."\n"."Here is the message:\n ".$Client_name.", ".$Client_Phone.", ".$Client_email.", ".$Type_of_Computer.", ".$Brand.", ".$Model.", ".$Operating_System.", ".$Errors_and_Issues; $to = "[email protected], [email protected]"; $headers = "From: $Client_email \r\n"; $headers .= "Reply-To: $Client_email \r\n"; mail($to,$email_subject,$email_body,$headers); } ?>

Fields with * are required.

Client Information
Name: *
Phone: *

(555) 555-0000

E-mail Address: *
Computer Information

Type of Computer: * Desktop/Tower Laptop Netbook Custom

Brand: * Acer Asus Compaq Dell Emachines Gateway HP Lenovo Sony Toshiba Custom

Model Number:

Operating System: * Windows XP Windows Vista Windows 7

Errors and Issues

Tell us what errors or issues you are experiencing, please try to include any error messages as best as possible *



[/php]

I hope this will helpful you and point you in right direction
Reply your feedback
SR

Lucien,

Your code will work as written except it is not being posted correctly. When you create a form,
it is posted to the ACTION area that is in the FORM tag. Currently, you have it posted to a webpage,
http://www.lfpctech.net/thanks/” … This will not work. You normally post it to a PHP page which
would use the php code you have posted here.

Sarthak, posted a way of combining the two pages onto one page. This works well and can be used
for your project.

But, usually, it is done with two pages. The html you gave us would be one page.
The ACTION area in the FORM tag would be the second page that would be your email code. Something
like: “sendemail.php/” … This page would be your PHP code and be called from the HTML page when the
submit button was pressed. You can add HTML to this page to indicate that the email was sent.
Something like, “Thank you for sending your notes to us. We will contact you shortly.” or whatever
you would like to display after sending an email.

Hope that helps. Two way to do this, either is good depending on your project needs.

Sponsor our Newsletter | Privacy Policy | Terms of Service