PHP Form Trouble.

This is a discussion on "PHP Form Trouble." within the PHP Forum section. This forum, and the thread "PHP Form Trouble. are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 7th, 2007, 17:49
Reputable Member
Join Date: Apr 2007
Location: Ireland
Age: 15
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Contact Form Trouble.

Sorry if this question has been asked before.

I'm having some trouble with my php contact form. Everything sends except the selected option in the question area.

HTML:
Code: Select all
<form action="php-contact-form.php" method="post">
     <p>Name:<br><input type="text" name="name"></p>
     <p>E-mail:<br><input type="text" name="email"></p>
     <p>Question:<br><select name="Question">
     <option value="Site Design">Site Design</option>
     <option value="Coding Your Mock-Up">Coding Your Mock-Up</option>
     <option value="Site Maintenance">Site Maintenance</option>
     <option value="Logo Design">Logo Design</option>
     <option value="Other">Other</option>
     </select></p>
     <p>Comments:<br><textarea name="comments" rows="6"    cols="35"></textarea></p>
     <p><input type="submit" value="Send"></p>
</form>
PHP:
Code: Select all
<?php
$subject = "New Email From PadraigCurran.com";
$your_email = "info@padraigcurran.com";
$success = "formdone.html";
$name = $_POST["name"];
$email = $_POST["email"];
$question = $_POST["question"];
$comments = $_POST["comments"];
$msg = "Name: $name\n";
$msg.= "E-mail: $email\n";
$msg.= "question: $question\n";
$msg.= "Comments: $comments";
mail($your_email, $subject, $msg);
header("Location: $success");
?>
The contact form can be found at http://padraigcurran.com/contact

Last edited by Pádraig; Jul 7th, 2007 at 19:14.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jul 7th, 2007, 20:05
Up'n'Coming Member
Join Date: Jul 2007
Location: France
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Trouble.

I'm just learning, so stand to be corrected. Your variable name under Select (HTML code) is "Question". Capital Q. All other references are lower case q.

In PHP that means they are two different variables. The capital Q wants altering to lower case.

Hope that helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jul 7th, 2007, 21:03
Reputable Member
Join Date: Apr 2007
Location: Ireland
Age: 15
Posts: 332
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Trouble.

It doesn't seem to have worked.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jul 7th, 2007, 22:25
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,794
Thanks: 0
Thanked 17 Times in 17 Posts
Re: PHP Form Trouble.

try:
Code: Select all
<?php
$subject = "New Email From PadraigCurran.com"; 
$your_email = "info@padraigcurran.com";
$success = "formdone.html"; 
$name = $_POST["name"];

$email = $_POST["email"];

$age = $_POST["Question"];

$comments = $_POST["comments"];

$msg = "Name: $name\n";

$msg.= "E-mail: $email\n";

$msg.= "Would Like: $Question\n";

$msg.= "Comments: $comments";

mail($your_email, $subject, $msg);
header("Location: $success");
?>
It may work but it may not!
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jul 7th, 2007, 22:36
Reputable Member
Join Date: Dec 2005
Location: U.S.A.
Posts: 155
Thanks: 0
Thanked 4 Times in 4 Posts
Re: PHP Form Trouble.

Unless someone has a better way and I'm sure they do. I believe you could list each list item in your email script and if it has been selected it will show the value you gave it (make sure you give each option a name). I know this works for radio buttons and check boxes. Might be worth a shot.

Good Luck,
Scott
__________________
Web Design and Development
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jul 8th, 2007, 09:23
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Trouble.

Here you go. This seems to work:
PHP: Select all

<html>
<head>
<title>echo select value</title>
</head>
<body>
<?php
$subject 
"New Email From PadraigCurran.com";
$your_email "info@padraigcurran.com";
$msg "Name: ".$_POST['name']."\n";
$msg.= "E-mail: ".$_POST['email']."\n";
$msg.= "question: ".$_POST['question']."\n";
$msg.= "Comments: ".$_POST['comments']."";
//mail($your_email, $subject, $msg);
echo("<p>".$msg."</p>");
?>

<form name="text" action="" method="post">
     <p>Name:<br><input type="text" name="name" /></p>
     <p>E-mail:<br><input type="text" name="email" /></p>
     <p>Question:<br><select name="question">
     <option value="Site Design">Site Design</option>
     <option value="Coding Your Mock-Up">Coding Your Mock-Up</option>
     <option value="Site Maintenance">Site Maintenance</option>
     <option value="Logo Design">Logo Design</option>
     <option value="Other">Other</option>
     </select></p>
     <p>Comments:<br><textarea name="comments" rows="6" cols="35"></textarea></p>
     <p><input type="submit" action="submit" value="Send" /></p>
</form>

</body>
</html>
I've never tested this thoroughly, but I think your problem is that PHP3&4 have the nasty habit of not keeping their variable maps for post / get / session / normal variables seperate. I've had the problem before that a session variable and a normal variable (ex: $_SESSION['bla'] and $bla) overwrite each other... Like I said, I'm not sure if that's true but I've had problems like this before.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
php, form

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with form controls. Height, width and all that magnetica Web Page Design 7 Aug 10th, 2007 12:47
Contact form trouble Ghost PHP Forum 10 Mar 10th, 2007 00:20
Having trouble with PHP voodoo465 PHP Forum 5 Feb 20th, 2007 21:47
CGI Trouble Maverick25r Other Programming Languages 0 Jul 31st, 2006 18:24
Trouble Getting Site Up M.K.Russ. PHP Forum 0 Apr 17th, 2006 15:59


All times are GMT. The time now is 17:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42