Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-15-2012, 08:57 AM   PM User | #1
lesh
New Coder

 
Join Date: Nov 2011
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
lesh is an unknown quantity at this point
Help with contact form

I am working on getting a contact form up and running for a website and have taken an example of someone else's. Only problem is I don't know anything about php so getting the form to work is proving difficult.

I have highlighted the lines I am unsure of with orange.
I don't know what I am supposed to put instead of junk@junk.om
Also, I am unsure how to change the URL to my contactthanks.html page. Everything I have tried will not work.

PHP Code:
<?php

// CHANGE THE VARIABLES BELOW

[COLOR="DarkOrange"]$EmailFrom "junk@junk.com";[/COLOR]
$EmailTo "aharper2000@hotmail.com";
$Subject "Contact Form Submission";

$Name Trim(stripslashes($_POST['Name'])); 
$Tel Trim(stripslashes($_POST['Tel'])); 
$Email Trim(stripslashes($_POST['Email'])); 
$Message Trim(stripslashes($_POST['Message'])); 

// prepare email body text
$Body "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

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

// redirect to success page
// CHANGE THE URL BELOW TO YOUR "THANK YOU" PAGE
if ($success){
  [
COLOR="DarkOrange"]print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">";[/COLOR]
}
else{
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
Any help would be appreciated.
Here is a link to what I've got working so far: http://ah.mjtippet.com/contact.html
lesh is offline   Reply With Quote
Old 01-15-2012, 11:32 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,647
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
For the first one, put whatever email you want it to arrive from.
For the second, use a header instead of a meta:
PHP Code:
if ($success)
{
    
header('Location: http://yoursite.com/yourthankspage.html');
    exit();
}
else
{
    
header('Location: http://yoursite.com/yourerrorpage.html');
    exit();

Fou-Lu is offline   Reply With Quote
Old 01-15-2012, 09:03 PM   PM User | #3
lesh
New Coder

 
Join Date: Nov 2011
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
lesh is an unknown quantity at this point
Thanks for your help. Are you able to tell me why you've changed it from print to header?
lesh is offline   Reply With Quote
Old 01-15-2012, 09:49 PM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
It isn't about the print, it is about what was printed. Originally it would print out some HTML which was a Meta refresh. This would rely on the browser understanding it (most browsers do but it is obsolete). Using the header it ensures that it will always work no matter what browser.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:14 PM.


Advertisement
Log in to turn off these ads.