Jump to content

order form doesnt wanna send all details


soulroll

Recommended Posts

Hi guys, i need your help with this form. when i press on send it doesnt wanna email me all details.

 

whats wrong in the code?

 

here is the link to the form:

http://www.bracksconsulting.com/index-6.html

 

 

here the html code for the form:

<div class="col_2">
			<div class="indent">
			  <form method="post" action="mail.php">
                    <p>
                      <input type="text" name="name" size="19" />
                      Name<br />
                      <br />
                      <input type="text" name="position" size="19" id="position" />
                      Position<br />
                      <br />
                      <input type="text" name="business name" size="19" id="business name" />
                      Business Name<br />
                      <br />
                      <input type="text" name="address" size="19" id="address" />
                      Business Address</p>
			    <p>
                      <input type="text" name="phone" size="19" id="phone" />
			      Business Phone</p>
			    <p>
                      <input type="text" name="web" size="19" id="web" />
			      Business Web Address</p>
			    <p>
                      <input type="text" name="email" size="19" id="email" />
		        Email Address </p>
			    <p>
			      <input type="text" name="number" size="19" id="number" />
			      Number of books to order@ $26 per book</p>
			    <p>
  <select name="Payment" size="1" id="Payment">
   <option value="Credit Card">Credit Card</option>
   <option value="Cheque">Cheque</option>
   <option value="Direct Funds Transfer" selected="selected">Direct Funds Transfer</option>
</select>
Method of payment<br />
			      <br />
			      <input type="submit" value="Submit" name="submit" />
			      <br />
		        </p>
		      </form>

 

here is the php code:

<?php
if(isset($_POST['submit'])) {

$to = "[email protected]"; // type your email add in here
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$position = $_POST['position'];
$business = $_POST['business'];
$adress = $_POST['adress'];
$web = $_POST['web'];
$number = $_POST['number'];

$body = "From: $name_field\n E-Mail: $email_field\n POSITION: $position_field\n BUSINESS NAME: $business name_field\n ADRESS: $adress_field\n PHONE: $phone_field\n WEBPAGE: $web_field\n NUMBER OF BOOKS: $number_field\n;

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "error in sending email!";

}
?>

 

and thats what i recieve per mail:

 

From: Demo

E-Mail: [email protected]

PHONE: 9875678999

Position:

business:

 

 

i dont get anything in the position form and business form. why do the rest doesnt show????

 

thanks for your help!!!

 

 

Two things are wrong.

 

In your form, the field for the business name is named "business name", not "business" as you are trying to retrieve in your script and you're putting the position value in the variable $position, but using $position_field.

 

Whenever you're having problems with forms, put the following at the top of your processing script

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>

This will dump all the values that are being sent to the script.

 

Ken

thanks ken. i changed it now, do you mean it like that? i uploaded the form, but now it doesnt wanna send anything???

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>{
<?php
if(isset($_POST['submit'])) {

$to = "[email protected]"; // type your email add in here
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$position = $_POST['position'];
$business = $_POST['business'];
$adress = $_POST['adress'];
$web = $_POST['web'];
$number = $_POST['number'];

$body = "From: $name E-Mail: $email POSITION: $position BUSINESS NAME: $business ADRESS: $adress PHONE: $phone WEBPAGE: $web NUMBER OF BOOKS: $number;

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "error in sending email!";

}
?>

 

 

You didn't fix what ken mentioned.

 

(...) In your form, the field for the business name is named "business name", not "business" as you are trying to retrieve in your script (...)

 

Also, I'm surprised you're not getting an error. You haven't closed off the $body variable properly. Take a look at the syntax highlighting in your post.

thanks, sorry im very new in php... is it right now?

$body = "From: $name E-Mail: $email POSITION: $position\n BUSINESS: $business\n ADRESS: $adress\n PHONE: $phone\n WEBPAGE: $web\n NUMBER OF BOOKS: $number\n;

 

 

what about this?

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>{
<?php
if(isset($_POST['submit'])) {

 

Not quite, you need the " at the end of the string:

$body = "From: $name E-Mail: $email POSITION: $position\n BUSINESS: $business\n ADRESS: $adress\n PHONE: $phone\n WEBPAGE: $web\n NUMBER OF BOOKS: $number";

 

That print_r($_POST) should show you all the data that is being sent via the form. If nothing is being shown at all then your form's action attribute is wrong.

 

You shouldn't need that lonely { that is there. And you don't need to close then re-open PHP.

 

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';

if(isset($_POST['submit'])) {

thanks again and for the patience.

i updated it now:

<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';

if(isset($_POST['submit'])) 

$to = "[email protected]"; // type your email add in here
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$position = $_POST['position'];
$business = $_POST['business'];
$adress = $_POST['adress'];
$web = $_POST['web'];
$number = $_POST['number'];

$body = "From: $name E-Mail: $email POSITION: $position\n BUSINESS: $business\n ADRESS: $adress\n PHONE: $phone\n WEBPAGE: $web\n NUMBER OF BOOKS: $number";

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "error in sending email!";

}
?>

 

but, now, when i press on submit, the window with

"your request has been send to [email protected]" doesnt apear anymore, only a empty window.

AND THE MAIL DOESNT COME THROUGH.

thats the link, you can try it out:http://www.bracksconsulting.com/index-6.html

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.