Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Scripts and Code Snippets
Reload this Page Why doesn't my Contact Form work??
Closed Thread
 
Thread Tools Display Modes
(#1 (permalink))
Old
Member
austin1988 is on a distinguished road
 
Posts: 97
Join Date: Jul 2010
Default Why doesn't my Contact Form work?? - 07-04-2010, 04:31 PM

Hi,

I've been having serious difficulty trying to get my contact form to work. I am very inexperienced with PHP, so I'd imagine this is a simple question.

I would greatly appreciate any help. Thanks in advance.

URL: http://www.austinlindsay.com/contact.html

Here's the code:

contact.html:

<div id="contact_form"><form method="POST" action="contact.php">
Fields marked (*) are required

<p>Email From:* <br>
<input type="text" name="EmailFrom">
<p>Subject: <br>
<input type="text" name="Subject">
<p>Name:<br>
<input type="text" name="Name">
<p>YourMessage:<br>
<textarea name="YourMessage"></textarea>
<p><input type="submit" name="submit" value="Submit">
</form>
<p>

<!-- Contact Form credit link -->
Created by <a target="_blank"
href="http://www.tele-pro.co.uk/scripts/contact_form/">Contact
Form Generator</a></div>

contact.php:

<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "jlindsay101@aol.com";
$Subject = Trim(stripslashes($_POST['Subject']));
$Name = Trim(stripslashes($_POST['Name']));
$YourMessage = Trim(stripslashes($_POST['YourMessage']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "YourMessage: ";
$Body .= $YourMessage;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Sponsored Links
(#2 (permalink))
Old
Member
Ranga is on a distinguished road
 
Posts: 36
Join Date: Jul 2010
Location: In a house
Default 07-04-2010, 06:04 PM

just a wild guess here but i believe it is because ur giving the ($Body .) to many variables, u might want to try to bracket them, EG.
$Body = ("","Name: ",$Name,"\n", "YourMessage: ",$YourMessage, "\n");
and i would possibly check the variables you have given it,it doesnt make sense to me.

but considering this looks kinda like a email couldnt you put something like

$body = "<body>(something to insert text here)</body>"
(#3 (permalink))
Old
Member
austin1988 is on a distinguished road
 
Posts: 97
Join Date: Jul 2010
Default 07-04-2010, 06:08 PM

Hey, thanks for your response.

I don't understand any of the code. I just found a website that generated the code for me.
(#5 (permalink))
Old
Member
austin1988 is on a distinguished road
 
Posts: 97
Join Date: Jul 2010
Default 07-04-2010, 07:09 PM

I'm having more luck with this one - the form submits but I do not receive the email, despite changing the email to: $my_email = "jlindsay101@aol.com";

Any idea where I'm going wrong?

Also, is there a way to remove the box around the text fields?

Thanks.
(#6 (permalink))
Old
Bad Karma[CORE]'s Avatar
Guilty as charged
Bad Karma[CORE] is on a distinguished road
 
Posts: 6,133
Join Date: May 2008
Default 07-04-2010, 07:13 PM

not sure what you mean with border around the text fields. If you mean the background behind the text fields just change
HTML Code:
<table border="0" style="background:#ececec" cellspacing="5">
to
HTML Code:
<table border="0" cellspacing="5">
Did you check your spam folder and/or made sure that mail from 000webhost.com servers isn´t blocked?
(#7 (permalink))
Old
Member
austin1988 is on a distinguished road
 
Posts: 97
Join Date: Jul 2010
Default 07-04-2010, 07:19 PM

Thanks, the background thing worked.


But yeah, I've checked my spam folder and I know that my mail from 000webhost isn't blocked because I receive a notification when a forum post has been made.

Is it definitely an issue with email accounts, or could it be something else?
(#8 (permalink))
Old
Bad Karma[CORE]'s Avatar
Guilty as charged
Bad Karma[CORE] is on a distinguished road
 
Posts: 6,133
Join Date: May 2008
Default 07-04-2010, 07:21 PM

have you got an alternative email account that you could try with? I know it works as i used googlemail.com and outlaw-forum.info when testing that script, as well as the mail address of my free hosting account here. Everything worked just fine....but then you have aol hehe
(#9 (permalink))
Old
Member
austin1988 is on a distinguished road
 
Posts: 97
Join Date: Jul 2010
Default 07-04-2010, 07:28 PM

I know. It's not the best email provider! But I've tried a different email address and it still doesn't work.

But it could be something else, maybe? I've placed it in a div tag, if that matters?
(#10 (permalink))
Old
Bad Karma[CORE]'s Avatar
Guilty as charged
Bad Karma[CORE] is on a distinguished road
 
Posts: 6,133
Join Date: May 2008
Default 07-04-2010, 07:35 PM

not really, placing it in a div tag shouldn´t matter (as long as you put the HTML part in a div container, not the php code in the contact.php file. Can you post the entire contents of your contact.php file please?
Closed Thread

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

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com