iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-12-2009, 08:43 AM
andthen's Avatar
WebProWorld Member
 
Join Date: Jun 2009
Location: UK
Posts: 27
andthen RepRank 0
Default Simple contact form help...please!?

Hi there folks,

I was just wondering if anybody could help me with a problem I'm having with a contact form not working?

Its a basic php form, I eventually want to integrate it into my contacts page but just for now I'm using two php pages, one for the form and a confirmation page. I have added a destination email address - have obviously omitted in this paste and I have enabled scripting on my domain.

Code:
Contact.php
<!-------INSERT THIS CODE WHERE YOU WOULD LIKE YOUR FORM TO BE------>

<?php>
$A= rand(1, 9);
$B= rand(1, 9);
$C=$A+$B;
?>
        <form method="post" action="contactus.php" >
        <table width="400" border="0"  align="left">
        <tr><td>Name:</td><td><input type="text" name="Name" size="20" maxlength="20"></td></tr>
        <tr><td>E-Mail:</td><td><input type="text" name="Email" size="20" maxlength="35"></td></tr>
        <tr><td>Phone:</td><td><input type="text" name="Phone" size="14" maxlength="14"></td></tr>
        <tr><td>Question:</td><td><textarea cols="40" rows="5" maxleanth="255" name="Comment"></textarea></td></tr>
        <tr><td><h3><?php echo $A."+".$B."="; ?></td><td>Please answer to validate your email.<input type="text" name="Yanswer" size="3" maxlength="3"></td></tr>
        <tr><td height="25"></td></tr>
        <input type="hidden" name="Answer" value="<?php echo "$C"; ?>">
        <tr><td></td><td><input type="submit" value="CONTACT US"></td></tr>
        <tr><td height="100"></td></tr>
        </table>
        </form>

<!------------------------------------------------------------------>

Contactus.php
<!------INSERT THIS CODE IN YOUR THANK YOU PAGE. IT SHOULD BE NAMED contactus.php-------->

<?php
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Phone=$_POST['Phone'];
$Comment = $_POST['Comment'];

//EDIT THE FOLLOWING LINE , INSERT THE SITE EMAIL
$To="myemailaddress.com";


$Subject="Contact form, Your Website";
$Answer=$_POST['Answer'];
$Yanswer=$_POST['Yanswer'];


$Message="
From: $Name
Phone: $Phone
Email: $Email
$Comment";


if ($Answer==$Yanswer){
mail($To,$Subject,$Message);
echo "<h3>Your message has been sent. Thank you.<table><tr><td height=\"1375\"></td></tr></table>";}
else{
echo "<h3>You did not enter the correct answer to the validation question. Please click back and try again.<table><tr><td height=\"1375\"></td></tr></table>";
}
                ?>

<!-------------------------------------------------------------------------------------->
Kind Regards,
Sukhjinder Singh

Last edited by rah; 08-12-2009 at 03:32 PM. Reason: Added code for his form
Reply With Quote
  #2 (permalink)  
Old 08-12-2009, 08:50 AM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 269
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Simple contact form help...please!?

Hello andthen

I'm happy to help out if I can... but you might have problems PM'ing code to me. Try it.
Reply With Quote
  #3 (permalink)  
Old 08-12-2009, 01:12 PM
rah's Avatar
rah rah is offline
Administrator
 
Join Date: Jul 2003
Location: Lexington, KY
Posts: 672
rah RepRank 4rah RepRank 4rah RepRank 4
Default Re: Simple contact form help...please!?

<edit>I found your code you were trying to post...</edit>

Last edited by rah; 08-12-2009 at 03:31 PM. Reason: Found code
Reply With Quote
  #4 (permalink)  
Old 08-12-2009, 04:08 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 269
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Simple contact form help...please!?

What exactly is wrong? (happening OR not happening).
Reply With Quote
  #5 (permalink)  
Old 08-12-2009, 04:19 PM
rah's Avatar
rah rah is offline
Administrator
 
Join Date: Jul 2003
Location: Lexington, KY
Posts: 672
rah RepRank 4rah RepRank 4rah RepRank 4
Default Re: Simple contact form help...please!?

I hadn't looked over his code, I just added it to his original post so it could be seen.
Reply With Quote
  #6 (permalink)  
Old 08-12-2009, 04:21 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 269
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Simple contact form help...please!?

Sorry rah.

I meant to ask andthen... but I've spotted the FIRST problem.

The first php tag, remove the greater than sign. <?php>

Now it works.

Last edited by Uncle Dog; 08-12-2009 at 05:43 PM.
Reply With Quote
  #7 (permalink)  
Old 08-12-2009, 05:10 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 269
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Simple contact form help...please!?

... andthen a whole lot more. andthen, where did you get this from?

Last edited by Uncle Dog; 08-12-2009 at 05:42 PM.
Reply With Quote
  #8 (permalink)  
Old 08-13-2009, 11:22 AM
andthen's Avatar
WebProWorld Member
 
Join Date: Jun 2009
Location: UK
Posts: 27
andthen RepRank 0
Default Re: Simple contact form help...please!?

Thanks for that Rah, very much appreciated!
Reply With Quote
  #9 (permalink)  
Old 08-13-2009, 11:45 AM
andthen's Avatar
WebProWorld Member
 
Join Date: Jun 2009
Location: UK
Posts: 27
andthen RepRank 0
Default Re: Simple contact form help...please!?

Well drats, i get the following error:

"Server Error 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed."

I realise I made a complete rookie mistake with the extra bracket at the start lol so I will try and figure this out myself as there must be something simple going on no? Anyways if theres anything else you could add please feel free to save my sanity and let me know!

Cheers
Reply With Quote
  #10 (permalink)  
Old 08-13-2009, 01:06 PM
Uncle Dog's Avatar
WebProWorld Pro
 
Join Date: Apr 2008
Location: Scotland
Posts: 269
Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5Uncle Dog RepRank 5
Default Re: Simple contact form help...please!?

Does contact.php work? Is it failing in contactus.php?
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Contact Form owt200x Internet Security Discussion Forum 0 01-15-2009 05:14 PM
Need to Build a Contact Form brianzajac Web Programming Discussion Forum 0 06-05-2006 06:20 PM
Contact Form being Hi-jacked - HELP! fisher318 Internet Security Discussion Forum 4 09-12-2005 03:14 PM


All times are GMT -4. The time now is 08:29 AM.



Search Engine Optimization by vBSEO 3.3.0