Website Babble Webmaster Forums  


Go Back   Website Babble Webmaster Forums > Creating a Website > HTML, PHP, CSS, Javascript & Coding/Programming Topics

Your WB Notifications

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-10-2009, 08:13 AM
sequencehosting's Avatar
Ultimate Babbler
 
Join Date: Jun 2009
Location: Kent, England
Posts: 1,338
sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)
Default Need some help with my PHP contact form!

Hello everyone!

Well I gave it my all but when the form is submited the email will only contain the a couple of details. Here is what I got from testing

From: ded
E-Mail: dedede@bill.com
Checked:
Option:
Drop-Down:
Message:

Im wondering if anyone can take a look to see if there is any errors in the php or html. Thanks allot!

Here is my code.

HTML Code:
<h3>Quote Form</h3>

<p>Please use the form below for a free website design quote and we will contact you by email as soon as possible. Please take a look at our <a href="/services/website-design.php">website design</a> page and our <a href="/company/portfolio.php">portfolio</a> for more information.</p>

<br />
<form method="post" action="/thankyou/website-design-quote.php">

First Name: 

<br /><input id="name" name="name" type="text" maxlength="255" value=""/><br /><br />

Last Name: 

<br /><input id="secondname" name="secondname" type="text" maxlength="255" value=""/><br /><br /> 

Email: 

<br /><input id="emailq" name="emailq" type="text" maxlength="255" value=""/><br /><br />

Phone Number: 

<br /><input id="phone" name="phone" type="text" maxlength="255" value=""/><br /><br />

Country: 

<br />
<select id="country">
<option value="" selected="selected"></option>
<option value="Australia" >Australia</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
</select>
<br /><br />

Brief Description Of Your Website / Project: 

<br /><textarea id="project" name="project"></textarea><br /><br />

Do You Currently Have A Website?

<br />
<select id="website" name="website"> 
<option value="" selected="selected"></option>
<option value="1" >Yes</option>
<option value="2" >No</option>
</select><br /><br />

Website Address: 

<br /><input name="url" type="text" maxlength="255" value="http://"/><br /><br />

Estimated Number Of Pages:

<br />
<select id="pages" name="pages"> 
<option value="" selected="selected"></option>
<option value="1" >1-5</option>
<option value="2" >6-15</option>
<option value="3" >16+</option>
</select><br /><br />

Requirements: 

<br />
<input name="requirements" type="checkbox" value="1" />
<label class="choice" for="element_11_1">Custom XHTML/CSS website</label><br />
<input id="element_11_2" name="element_11_2" class="element checkbox" type="checkbox" value="1" />
<label class="choice" for="element_11_2">Wordpress CMS</label><br /><br />

Budget:

<br />
<select id="buget" name="buget"> 
<option value="" selected="selected"></option>
<option value="1" >Under &pound;100</option>
<option value="2" >&pound;100-&pound;300</option>
<option value="3" >&pound;300-&pound;600</option>
<option value="4" >&pound;600+</option>
</select><br /><br />

Prefered Contact Method: 

<br />
<select id="contactmethod" name="contactmethod"> 
<option value="" selected="selected"></option>
<option value="1" >Email</option>
<option value="2" >Phone</option>
</select><br /><br />

<input type="hidden" name="form_id" value="91337" />
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</form>
PHP Code:
<?php
if(isset($_POST['submit']))
{


$to = "myemail";
$subject = "title";
$name_field = $_POST['name'];
$email_field = $_POST['emailq'];
$message = $_POST['message'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];

$check_msg .= "Checked: $value\n";

$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";

echo
"Thank for for your quote, we will reply as soon as possible.";
mail($to, $subject, $body);


}
else
{

echo
"blarg!";

}
?>
I will be the first to admit I really don't know much about PHP yet but I do plan on learning it soon.

Thanks for any help
__________________
Professional Website Hosting - Now Hosting Over 75 Websites! >Testimonials<
Professional cPanel Web Hosting from $1/month!
Our Disk Space and Bandwidth Has Been Doubled! Learn More
WEBSITE BABBLE SPECIAL! FREE Domain! - FREE Wordpress Setup! - 24 Hour Support
Reply With Quote
  #2 (permalink)  
Old 09-10-2009, 09:45 AM
Master Babbler
 
Join Date: Sep 2009
Posts: 152
Coder is a reputable WB member and has over 100 reputation pointsCoder is a reputable WB member and has over 100 reputation points
Default

Hi,

The problem is that you are assigning values based on non-existent form elements.

Take a look at this PHP block from your code:

PHP Code:
$message = $_POST['message'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];

$check_msg .= "Checked: $value\n";
There are no form elements named "message","radio" or "drop_down". Naturally this means that these variables are empty. The $value variable on the last line doesn't exist in the code previously, so it is created on the spot, but has no value.

You are referencing form elements in your PHP that do not exist, but there are also form elements in your HTML that you ignore in your PHP (which makes them redundant I would think).

Hope this helps
Reply With Quote
  #3 (permalink)  
Old 09-12-2009, 07:58 AM
sequencehosting's Avatar
Ultimate Babbler
 
Join Date: Jun 2009
Location: Kent, England
Posts: 1,338
sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)
Default

Quote:
Originally Posted by Coder View Post
Hi,

The problem is that you are assigning values based on non-existent form elements.

Take a look at this PHP block from your code:

PHP Code:
$message = $_POST['message'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];

$check_msg .= "Checked: $value\n";
There are no form elements named "message","radio" or "drop_down". Naturally this means that these variables are empty. The $value variable on the last line doesn't exist in the code previously, so it is created on the spot, but has no value.

You are referencing form elements in your PHP that do not exist, but there are also form elements in your HTML that you ignore in your PHP (which makes them redundant I would think).

Hope this helps

Thank you very much for your reply. Looks like I have a lot to learn and you have certainly pointed me in the right direction!
__________________
Professional Website Hosting - Now Hosting Over 75 Websites! >Testimonials<
Professional cPanel Web Hosting from $1/month!
Our Disk Space and Bandwidth Has Been Doubled! Learn More
WEBSITE BABBLE SPECIAL! FREE Domain! - FREE Wordpress Setup! - 24 Hour Support
Reply With Quote
  #4 (permalink)  
Old 09-16-2009, 09:47 AM
Regular Babbler
 
Join Date: Sep 2009
Posts: 34
uptown47 has no reputation at Website Babble yet.
Default

Hii sequence,

As coder says you are not using the correct names when recieving the info.

You have some code here:
Code:
<select id="country">
<option value="" selected="selected"></option>
<option value="Australia" >Australia</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
</select>
There is no "name" defined and you need a "name" to get the info once its been passed through the form.

So you could use:
Code:
<select id="country" name="myCountry">
<option value="" selected="selected"></option>
<option value="Australia" >Australia</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
</select>
Then in your php have:
Code:
$countryChosen = $_POST['myCountry'];
With your 'pages' value you have written the name:
Code:
<select id="pages" name="pages"> 
<option value="" selected="selected"></option>
<option value="1" >1-5</option>
<option value="2" >6-15</option>
<option value="3" >16+</option>
</select>
But you have nothing on the server side (i.e. in your php) to recieve the name.
Code:
$nameChosen = $_POST['pages'];
Hope that makes some sense...



Something like:
Reply With Quote
  #5 (permalink)  
Old 09-16-2009, 12:07 PM
sequencehosting's Avatar
Ultimate Babbler
 
Join Date: Jun 2009
Location: Kent, England
Posts: 1,338
sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)sequencehosting has a stellar WB reputation (over 400 points)
Default

Quote:
Originally Posted by uptown47 View Post
Hii sequence,

As coder says you are not using the correct names when recieving the info.

You have some code here:
Code:
<select id="country">
<option value="" selected="selected"></option>
<option value="Australia" >Australia</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
</select>
There is no "name" defined and you need a "name" to get the info once its been passed through the form.

So you could use:
Code:
<select id="country" name="myCountry">
<option value="" selected="selected"></option>
<option value="Australia" >Australia</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
</select>
Then in your php have:
Code:
$countryChosen = $_POST['myCountry'];
With your 'pages' value you have written the name:
Code:
<select id="pages" name="pages"> 
<option value="" selected="selected"></option>
<option value="1" >1-5</option>
<option value="2" >6-15</option>
<option value="3" >16+</option>
</select>
But you have nothing on the server side (i.e. in your php) to recieve the name.
Code:
$nameChosen = $_POST['pages'];
Hope that makes some sense...



Something like:
Thank you very much that was very helpful.

Im going to give this another shot soon and I will post here how it goes
__________________
Professional Website Hosting - Now Hosting Over 75 Websites! >Testimonials<
Professional cPanel Web Hosting from $1/month!
Our Disk Space and Bandwidth Has Been Doubled! Learn More
WEBSITE BABBLE SPECIAL! FREE Domain! - FREE Wordpress Setup! - 24 Hour Support
Reply With Quote
  #6 (permalink)  
Old 09-16-2009, 03:57 PM
Regular Babbler
 
Join Date: Sep 2009
Posts: 34
uptown47 has no reputation at Website Babble yet.
Default

No problem. Will try and help you out if I can. ;-)
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -6. The time now is 10:28 AM.


 Subscribe to RSS

WB Sponsors

flash chat

Home Jobs Online

Search Engine Marketing

Paid Surveys

Web Design Newcastle



 Subscribe to the Website Babble Feeds

2 Create a Website Homepage | 2 Create a Website Blog


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0