Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsZymic Free Web HostingZymic Free Web Hosting - General Discussion & Help right
  Reply to this topic Start new topic
left right
Bigdog12
post May 8 2012, 08:07 AM
Post #1


Newbie
*

Group: Members
Posts: 4
Joined: 8-May 12
Member No.: 241,014



Im trying to make a simple contact form for my site, but im having trouble figuring this out. I have little to no knowledge of php, so i looked online.

This is the page the form is on,

http://briansmithwebdesign.com/contact.html

and on the site i got the how to they said to create a php page, with this coding

QUOTE
<?php

$my_email = "email@yorhost.com";

/*

Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage.

If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"

*/

$continue = "http://briansmithwebdesign.com/thankyou.html";

/*

Step 3:

Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there.

THAT'S IT, FINISHED!

You do not need to make any changes below this line.

*/

$errors = array();

// Remove $_COOKIE elements from $_REQUEST.

if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}

// Check all fields for an email header.

function recursive_array_check_header($element_value)
{

global $set;

if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}}
else
{

foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}

}

}

recursive_array_check_header($_REQUEST);

if($set){$errors[] = "You cannot send an email header";}

unset($set);

// Validate email field.

if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
{

if(preg_match("/(%0A|%0D|\n+|\r+|smile.gif/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}

$_REQUEST['email'] = trim($_REQUEST['email']);

if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}

}

// Check referrer is from same site.

if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}

// Check for a blank form.

function recursive_array_check_blank($element_value)
{

global $set;

if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{

foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}

}

}

recursive_array_check_blank($_REQUEST);

if(!$set){$errors[] = "You cannot send a blank form";}

unset($set);

// Display any errors and exit if errors exist.

if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}

if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}

// Build message.

function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}

$message = build_message($_REQUEST);

$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";

$message = stripslashes($message);

$subject = "FormToEmail Comments";

$headers = "From: " . $_REQUEST['email'];

mail($my_email,$subject,$message,$headers);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<title>Dreamweaver Tutorial - Contact Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#ffffff" text="#000000">

<div>
<center>
<b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
<br>Your message has been sent
<p><a href="<?php print $continue; ?>">Click here to continue</a></p>
<p><b>Dreamweaver Spot</b> by <a href="http://dreamweaverspot.com">dreamweaverspot.com</a></p>
</center>
</div>

</body>
</html>


Anyone have an idea as to what i need to change or do?
Go to the top of the page 
 
  + Quote Post
ssfdre38
post May 8 2012, 03:46 PM
Post #2


THE SILENT FORUM NINJA
*******

Group: Administrators
Posts: 3,706
Joined: 23-January 10
From: on your screen
Member No.: 127,507



pay for mail() in order to use it
Go to the top of the page 
 
  + Quote Post
Bigdog12
post May 9 2012, 05:38 PM
Post #3


Newbie
*

Group: Members
Posts: 4
Joined: 8-May 12
Member No.: 241,014



QUOTE(ssfdre38 @ May 8 2012, 03:46 PM) *
pay for mail() in order to use it

I did
Go to the top of the page 
 
  + Quote Post
ssfdre38
post May 9 2012, 06:02 PM
Post #4


THE SILENT FORUM NINJA
*******

Group: Administrators
Posts: 3,706
Joined: 23-January 10
From: on your screen
Member No.: 127,507



how long ago cause it takes 48 hrs
Go to the top of the page 
 
  + Quote Post
Bigdog12
post May 10 2012, 05:01 AM
Post #5


Newbie
*

Group: Members
Posts: 4
Joined: 8-May 12
Member No.: 241,014



QUOTE(ssfdre38 @ May 9 2012, 06:02 PM) *
how long ago cause it takes 48 hrs


I have the comfirmation saying its enabled,

Im having issues making it work as i am not familiar with how to use php, i can make the form, just not the alternate page to make it send. Anyone wanna help, please?

www.briansmithwebdesign.com/contact.html
Go to the top of the page 
 
  + Quote Post
ssfdre38
post May 10 2012, 03:27 PM
Post #6


THE SILENT FORUM NINJA
*******

Group: Administrators
Posts: 3,706
Joined: 23-January 10
From: on your screen
Member No.: 127,507



change it from contact.html to contact.php so the php coding can work
Go to the top of the page 
 
  + Quote Post
Bigdog12
post May 12 2012, 02:31 AM
Post #7


Newbie
*

Group: Members
Posts: 4
Joined: 8-May 12
Member No.: 241,014



QUOTE(ssfdre38 @ May 10 2012, 03:27 PM) *
change it from contact.html to contact.php so the php coding can work


It links to a pho page, with an action in the form linking to the pup with where to send it to,

I updated it though with the pho coding on the main form, but what should I put for the action?
Go to the top of the page 
 
  + Quote Post
zpcs
post May 12 2012, 02:03 PM
Post #8


Marvellous Ninja
******

Group: Members
Posts: 568
Joined: 10-May 09
From: Wisconsin state, United States of America
Member No.: 94,482



Hi Bigdog12,
For the Form Action use the php file "FormToAction.php" file (that is if you didn't change the name of the original FormToEmail.php). If you noticed, at the website that the script may be found at, the tutorial guide there mentions (in typo) the name of the file to be "FormtoEmail.php" not the actual existing name of the file being "FormToEmail.php". If you should encounter a problem still, use the long action call (e.g.: http://briansmithwebdesign.com/FormToEmail.php).
When first learning don't cut yourself short by using abbrevated methods - spell it out completely until you've learned the fundamentals then shortcut yourself.

Thank you, Bigdog12. Your POST here at Zymic did allow me the possibility of a "Contact Form" even though I had initially encountered problem(s) with it functioning. A problem which turned out (I believe) to be an issue far afield of the FormToEmail script. Concerning the issue, a past (previous) assignment of the web domain numbers (e.g.: 12.345.67.891 of my site) where I experimented with the FormToEmail was in a poor reputation condition. That "poor" rating was remedied within 24 hours from Thursday the 11th via a Domain reputation service.
Thanks to your POST here, I now have a working php Contact Form that I can use as a learning tool in my webmastering informal education (Zymic WEBMASTER RESOURCES Community has been my informal education instructor - which is so advantageous for me learning everything I have come to apply in web page creation(s) from fundamental HTM[L] Valid Coding into CSS and some Javascript and now into expanding into the PHP and MySQL arenas. Believe me, I've a long ways yet to go but I'm ahead of some of the crowd and well in the top percentile of people as ancient as I am).

I was not looking for the Contact Form at this particular time but (with your advent being coupled with my desire to check out possibilities to make my life easier) something I'd most likely have need for in the future.

As a precaution for the use of others' scripts before you actually employ it for public (web published) use:
  • spend some time and reverse engineer the script to ensure that there is no "Evilness" residing in it. (Make sure there is proper sanitization within the script. Many unsuspecting script users have caused damage and/or comprimised their web security to their work(s) they have spent a great deal of time creating by simply grabbing off the Internet because they themselves looked for an easy way out to get a quickie.)
Hope this helps you out.
Go to the top of the page 
 
  + Quote Post
 Reply to this topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 20th May 2013 - 08:41 PM