Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
My contact form is killing me, please help
Old 11-30-2009, 07:33 PM My contact form is killing me, please help
smather06's Avatar
Junior Talker

Posts: 1
Name: Scott
Location: Florida
Trades: 0
Hello all, I am relatively new to all of this and especially php. I have built my site using a template and I am having massive difficulties getting the contact form to work. I have tried dozens of php scripts, and even a dreamweaver extension, and nothing seems to work. The current version that has at least gotten me emails is below, but it is not passing me any info, it is just showing "Results from form:" in the email and that is it, no form data at all. Any suggestions what is wrong? I am guessing since I am actually getting an email of some sort that it is not on the hosting side.

Here is the HTML code for the form:
HTML Code:
<form action="contact.php" method="post" id="form1">
                                            <div class="form">
                                              <label>Enter your name</label>
                                              <input type="text" id="Name" />
                                            </div>
                                            <div class="form">
                                              <label>Enter your e-mail</label>
                                              <input type="text" id="email" />
                                            </div>
                                            <div class="form">
                                              <label>Enter your phone number</label>
                                              <input type="text" id="phone" />
                                            </div>
                                            <div>
                                              <label>Enter your message</label>
                                              <textarea cols="1" rows="1" id="comments"></textarea>
                                            </div>
                                            <div class="link1"><a href="#" onclick="document.getElementById('form1').reset()"><em><b>Clear</b></em></a> &nbsp; <a href="#" onclick="document.getElementById('form1').submit()"><em><b>Send</b></em></a></div>
                                          </form>


And this is the php code in the contact.php file:
PHP Code:
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject 'Results from Contact form'
// Your email address. This is where the form information will be sent. 
$emailadd 'info@lightingbydesignfl.com'
// Where to redirect after form is processed. 
$url 'http://www.lightingbydesignfl.com/index-6.html'
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req '1'
// --------------------------Do not edit below this line--------------------------
$text "Results from form:\n\n"
$space ' ';
$line ' ';
foreach (
$_POST as $key => $value)
{
if (
$req == '1')
{
if (
$value == '')
{echo 
"$key is empty";die;}
}
$j strlen($key);
if (
$j >= 20)
{echo 
"Name of form element $key cannot be longer than 20 characters";die;}
$j 20 $j;
for (
$i 1$i <= $j$i++)
{
$space .= ' ';}
$value str_replace('\n'"$line"$value);
$conc "{$key}:$space{$value}$line";
$text .= $conc;
$space ' ';
}
mail($emailadd$subject$text'From: '.$emailadd.'');
echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>


Any thoughts would be most appreciated.
smather06 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-30-2009, 08:01 PM Re: My contact form is killing me, please help
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Have you tried MachForm? Very simple!
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-01-2009, 12:08 AM Re: My contact form is killing me, please help
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
Are you naming your inputs or just using id's?

FYI- it is good to learn all this, but be sure to validate your forms for malicious content. If not, try what Brian07002 said and use a form maker.
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 12-01-2009, 12:59 PM Re: My contact form is killing me, please help
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Yeah, give your stuff names as well.

<input type="text" id="Name" name="Name" />


Also,
Rather than getting the data as keys.
Try
$name = $_POST['name'];
$email = $_POST['email'];

Etc.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Reply     « Reply to My contact form is killing me, please help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67636 seconds with 12 queries