I can't get the Form to work.

HTML file… I can’t get the form to work. Please

[code]

Translations-Design Services| TDS

Who we are | Translation Services | Web Publishing Services | Contact Us
Translation Process
</td>

<td>	


	
		<form id="form" action="formdata.php" method="post" enctype="text/plain" autocomplete="on" target="_blank">

		<fieldset>
		<legend>Get a FREE Quote</legend>
			  <label for="flname">First and Last name:</label><input type="text" name="flname" autofocus placeholder="Please type your first and last name." size="40" required /><br>
			 <!-- <label for="lname">Last name: </label><input type="text" name="lname" autofocus placeholder="Please type your last name." size="40" required><br>-->
			  <label for="email">E-mail: </label><input type="email" name="email" autocomplete="off" autofocus placeholder="Please type your e-mail." size="40" required /><br>
			  <label for="tel">Telephone: </label><input type="text" name="tel" autofocus placeholder="Please enter your phone number." size="40" required /><br>
			  Describe Request:<textarea name="DescRequest" autofocus placeholder="Please describe your request." maxlength="500" required></textarea><br>
			  Service Required:
			  					<select name="dropdown">
					               <option value = "select">Please select one.</option>
					               <option value = "translation">Translation</option>
					               <option value = "web">Web Design</option>
					             </select>	       
			<br>
			  <input type="submit" name="submit" value="Get FREE Quote" id="buttonCenter">
			  <input type="reset" value="Reset" id="buttonCenter">
			  </fieldset>
			</form> 

</td>

© 2014 Mau-Kem Translations. All rights reserved.

[/code]

HERE’S THE PHP FILE

[php]

<?php //declare variables first $flname = $_POST['flname']; $email = $_POST['email']; $tel = $_POST['tel']; $descRequest = $_POST['descRequest']; $dropdown = $_POST['dropdown']; $from = 'From: Translations Designs'; $to = '[email protected]'; $subject = 'Hello'; $body = "From: $flname\n E-Mail: $email\n Telephone: $tel\n Description Request: $DescRequest\n Service Required: $dropdown"; //then execute if ($_POST['submit']) { if (mail ($to, $subject, $body, $from)) { echo '

Your request has been sent!

'; } else { echo '

Something went wrong, go back and try again!

'; } } ?>

[/php]

Please add any errors or descriptions of problems you are having. “Doesn’t work” makes it a lot harder to help.

Yes Sorry. Here’s the errors I am getting- Undefined index errors

( ! ) Notice: Undefined index: flname in C:\wamp\www\formdata.php on line 5
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

( ! ) Notice: Undefined index: email in C:\wamp\www\formdata.php on line 6
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

( ! ) Notice: Undefined index: tel in C:\wamp\www\formdata.php on line 7
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

( ! ) Notice: Undefined index: descRequest in C:\wamp\www\formdata.php on line 8
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

( ! ) Notice: Undefined index: dropdown in C:\wamp\www\formdata.php on line 9
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

( ! ) Notice: Undefined variable: DescRequest in C:\wamp\www\formdata.php on line 13
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

( ! ) Notice: Undefined index: submit in C:\wamp\www\formdata.php on line 19
Call Stack

Time Memory Function Location

1 0.1056 140672 {main}( ) …\formdata.php:0

[php]if ($_POST[‘submit’]) {[/php]

this line checks if the value of $_POST[‘submit’] is truthy, not if the variable is set.

I would wrap the entire form handling in

[php]if (isset($_POST[‘submit’])) {
// all form stuff
}[/php]

then you can remove the if($_POST[‘submit’]) you already have.

[hr]

The above should take care of the undefined indexes, the undefined variable error is just a typo.

[php]$descRequest = $_POST[‘descRequest’];

// vs

$body = “From: $flname\n E-Mail: $email\n Telephone: $tel\n Description Request: $DescRequest\n Service Required: $dropdown”;[/php]

The HTML form code should go in the //all form stuff? or the php code?

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

// all form stuff
}

php

Thanks you so much for your help. So it look like this now. I am still getting the undefined index for flname, email, tel, descRequest, and dropdown

[php]

<?php //declare variables first $flname = $_POST['flname']; $email = $_POST['email']; $tel = $_POST['tel']; $descRequest = $_POST['descRequest']; $dropdown = $_POST['dropdown']; $from = 'From: Translations Designs'; $to = '[email protected]'; $subject = 'Hello'; $body = "From: $flname\n E-Mail: $email\n Telephone: $tel\n Description Request: $descRequest\n Service Required: $dropdown"; //then execute if (isset($_POST['submit'])) { // all form stuff if (mail ($to, $subject, $body, $from)) { echo '

Your request has been sent!

'; } else { echo '

Something went wrong, go back and try again!

'; } } ?>

[/php]

[php]<?php

if (isset($_POST[‘submit’])) {
// ALL form stuff ^^

//declare variables first
$flname = $_POST[‘flname’];
$email = $_POST[‘email’];
$tel = $_POST[‘tel’];
$descRequest = $_POST[‘descRequest’];
$dropdown = $_POST[‘dropdown’];
$from = ‘From: Translations Designs’;
$to = ‘[email protected]’;
$subject = ‘Hello’;
$body = “From: $flname\n E-Mail: $email\n Telephone: $tel\n Description Request: $descRequest\n Service Required: $dropdown”;

//then execute
if (mail ($to, $subject, $body, $from)) {
echo ‘

Your request has been sent!

’;
} else {
echo ‘

Something went wrong, go back and try again!

’;
}

}[/php]

Thanks alot. Now I just need to get the confirmation to work. I test it it directs me to the action=“formdata.php” (blank nothing appear) I wonder if I should move the php code to the html page below the form so that the confirmation request can appear below the submit button ? I probably would have to save it as php for it to work?

Sponsor our Newsletter | Privacy Policy | Terms of Service