Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 08:19:00 PM

Pages: [1]   Go Down
  Print  
Author Topic: How do I get the submit button on my contact page to work?  (Read 1346 times)
easyl13
Space Explorer
***
Offline Offline

Posts: 6


« on: June 25, 2010, 08:58:49 PM »

I used PageMason Sitebuilder to build my website and included a contact form but when I click submit, there is an error message "Oops, this link appears to be broken". I want it to email me the data in the form. What am I doing wrong?

Ps. This is my first website to please explain in detail   Smiling
Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #1 on: June 25, 2010, 09:38:26 PM »

whatever you have listed in your action= in the form is what it will execute on submit...    give me just a min and i will post a sample for you , by the way dont get too attached to that site builder, before you know it you will grow your skills enough to want more than a sitebuilder can offer and you will want to write your own site... just a thought, dont get youself locked in to tight with that you shoot yourself in the foot when that times comes.. my personal experience has not been too positive with that particular program, i played with it a bit a while back and it was choppy and not very user friendly..

ok here ya go here is a sample... most pass the data to a function or other php file to process the form...
 
code has been moved to a lower post..

« Last Edit: June 26, 2010, 11:35:02 PM by durangod » Logged
easyl13
Space Explorer
***
Offline Offline

Posts: 6


« Reply #2 on: June 26, 2010, 01:08:15 PM »

Thanks your help! Unfortunately, I'm still not doing something right. Everytime I click on the submit button, I get the same error. Where do I put in my email address so it knows where to send the data. What should the 'name' and 'action' field in my form include? Thanks for your patience!
Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #3 on: June 26, 2010, 03:14:16 PM »

the action is where you want to send the data to process it.. such as my example... you post the data in the form on that page then you press submit and it sends the data to the process php file to actually process the entry...

the name is the the name of your form.....   the form in the example is not named just fyi..

does that help... maybe you can post what your seeing that might help us to help you
Logged
easyl13
Space Explorer
***
Offline Offline

Posts: 6


« Reply #4 on: June 26, 2010, 05:22:04 PM »

Ok, I basically just copied and pasted your example and it put the form on my page. I'm just not sure what to do from there. I can edit the form properties and a box pops up with 'action', 'name', and 'method' (POST or GET). I'm not sure what to put into these fields. I'm guessing my email address goes in one of them?? I also tried to copy and paste your second example but it came out all weird because I know I have to change some areas to fill in my personal info. All these codes scare me...it's the first time I've seen them so I really have no idea what I'm doing! I created my own form using the form icon in pagemason and I the form showed up clearly, I just don't know how to connect that with my email.








Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #5 on: June 26, 2010, 10:15:47 PM »

ok i understand how scary it can seem i have been there but theres is nothing in there that is scary ok... its ok...

ok i think i understand...

i put that sample up there not for execution per say beause its not named properly..... i didnt think you would just copy it verbatim lol   just put that on there so you could reference the flow and the basics ...

give me just a few and let me edit the code post and then it will work for you sorry about that...   

Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #6 on: June 26, 2010, 11:45:17 PM »

ok here ya go i just tested it and it will work just fine for you..

you need to make two files, names will be posted above the code...

first you need to make a file called  contactform.html

inside that file copy and paste this...

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
<head>
   <title>Contact Form</title>
 </head>

<body>

<form name="contactform" method="post" action="send_form_email.php">
<table width="450px">
</tr>
<tr>
 <td valign="top">
  <label for="first_name">First Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="first_name" maxlength="50" size="30">
 </td>
</tr>

<tr>
 <td valign="top"">
  <label for="last_name">Last Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email Address *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
 </td>

</tr>
<tr>
 <td valign="top">
  <label for="telephone">Telephone Number</label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="comments">Comments *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>

</tr>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit">    </td>
</tr>
</table>
</form>
 

</body>
</html>

now make a new file called  send_form_email.php



first things first
Quote
DONT FORGET TO CHANGE YOUR EMAIL AT THE TOP OF THIS FILE where it says pur your email here, put your email address

now copy and paste the corrected code in your file and save it.

Code:
<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to "PUT YOUR EMAIL HERE";
$email_subject "Customer Contact";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";

                                           if (isset(
$HTTP_REFERER)) { 
echo 
"<br /><br /><a href='$HTTP_REFERER'>GO BACK</a>"
} else { 
echo 
"<br /><br /><a href='javascript:history.back()'>GO BACK</a>"
}    

die();
}

// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form your submitted.');
}

$first_name $_POST['first_name']; // required
$last_name $_POST['last_name']; // required
$email_from $_POST['email']; // required
$telephone $_POST['telephone']; // not required
$comments $_POST['comments']; // required

$error_message "";
$email_exp "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  if(!
eregi($email_exp,$email_from)) {
  
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
$string_exp "^[a-z .'-]+$";
  if(!
eregi($string_exp,$first_name)) {
  
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!
eregi($string_exp,$last_name)) {
  
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(
strlen($comments) < 2) {
  
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  
$string_exp "^[0-9 .-]+$";
  if(!
eregi($string_exp,$telephone)) {
  
$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  }
  if(
strlen($error_message) > 0) {
  
died($error_message);
  }
$email_message "Form details below.\n\n";

function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:","href");
  return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' phpversion();
@
mail($email_to$email_subject$email_message$headers);  
?>


<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?
}
?>
 


Thanks it your done...

Code:
just type in your browser www.yoursite.com/contactform.html

« Last Edit: June 26, 2010, 11:49:16 PM by durangod » Logged
easyl13
Space Explorer
***
Offline Offline

Posts: 6


« Reply #7 on: June 29, 2010, 11:48:05 AM »

Thank you so much for those codes! I copied and pasted (after I edited) them into 2 files on my computer (using notepad) and then uploaded those files into filezilla, but I'm not sure where to go from there or if that step was even necessary since I'm using pagemason. When I open them, they are showing up correctly. Now I just can't figure out how to put the files onto my contact page using pagemason. I uploaded them into file manager through pagemason but I'm sure I'm not supposed to upload them as 'insert image'. I don't see any other way to do it. I've tried to just copy and past straight into pagemason and the form turns out fine when I go to my contact page, but the 'send_form_email' codes come out all weird.  Is pagemason the problem, or am I just making it extremely difficult? Confused
Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #8 on: June 29, 2010, 07:05:56 PM »

i was working on a project today and didnt have time to check in but here ya go this should help..

im not that familiar with pagemason but i assume if its like most site builders it allows you to insert some html into your page...

in the main part of your page use iframe to display the form..

sample
Code:
<center><iframe src="http://www.xxxxxxx.com/contactform.html" width="80%" height="600" frameborder="0" ></iframe></center>

just make sure you have the url correct for werever your file is located at.

you can adjust the width and height if you wish..

here is a tip, i use percent on the width and height most of the time because if you dont then it wont display correct on larger monitors.   80 percent is 80 percent no  matter what.. 80px will only display 80px on any monitor. just get into the habbit of using percent whenever you can for tables and any widths  heights you use.. its just better..

now i didnt use a percent on the height of this just because i chose not to. but you can if you want..

one more thing adjust the height and width so that you dont have a scroll bar on the side or bottom, there is an option with iframe for no scroll bar but then it leaves  you with a dorky dead space around your image just adjust it so its tight and youll be fine, you can  google html iframe for some options.
« Last Edit: June 29, 2010, 07:09:26 PM by durangod » Logged
easyl13
Space Explorer
***
Offline Offline

Posts: 6


« Reply #9 on: June 30, 2010, 05:46:42 PM »

Ok, so I'm successfully uploading the contact form in pagemason and it's showing up correctly on my site. However, when I copy and pasted the send email code you gave me, it shows up exactly the way it appears below (the entire code) on my site. So it looks like this:

The form, correctly displayed and then everything below:


if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "ampeterson@easylivingnc.com";
$email_subject = "Customer Contact";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.

";
echo $error."

";
echo "Please go back and fix these errors.

";

if (isset($HTTP_REFERER)) {
echo "

GO BACK";
} else {
echo "

GO BACK";
}

die();
}

// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form your submitted.');
}

$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required

$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.
';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.
';
}
if(!eregi($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.
';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.
';
}
$string_exp = "^[0-9 .-]+$";
if(!eregi($string_exp,$telephone)) {
$error_message .= 'The Telphone Number you entered does not appear to be valid.
';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

Thank you for contacting us. We will be in touch with you very soon.

}
?>
Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #10 on: June 30, 2010, 06:20:27 PM »

ok now i think i see what your doing wrong.. your just misundering how it works thats all and its ok...

you dont copy and paste the process file,  here  is how it works

you have the form on your page, (the form part (the first file you made) this is the html code that you put in your page

the second file you just have stored in the same dir (or whatever  dir you want to call it from in your action command)  you dont have to copy and paste that process in your html page...

when someone fills out the form and clicks send it goes wherever you address that process file at (where ever it is sitting on your server or file structure

example...  in your form lets say you have action= gorunmyfile.php

as soon as someone hits send it will go look for a file on your system named gorunmyfile.php and it will process whats iniside it.   dont paste the process file on your page, its a php file anyway...


just have it on your server and call it when you need it

the only file you need to post in your html is the form file

does that make sense
« Last Edit: June 30, 2010, 06:22:24 PM by durangod » Logged
easyl13
Space Explorer
***
Offline Offline

Posts: 6


« Reply #11 on: June 30, 2010, 06:31:26 PM »

Ok that makes sense! I just created my own form and was wondering if I follow the same steps will it work? Or do I need a different send mail code than what you gave me? Also, do I want the GET or POST option for my form? Here's what the form that I would rather have looks like:

<form name="" method="get">
    <p>&nbsp;</p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-size: small;"><span style="font-family: Verdana;">Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <input type="text" name="" />&nbsp; </span></span></span></b></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-size: small;"><span style="font-family: Verdana;">Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <input type="text" name="" /></span></span></span></b></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-size: small;"><span style="font-family: Verdana;">Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; <input type="text" name="" /><br />
    </span></span></span></b></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-size: small;"><span style="font-family: Verdana;">Address (For mileage purposes):&nbsp; <input type="text" name="" /></span></span></span></b></p>
    <p>&nbsp;</p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-size: small;"><span style="font-family: Verdana;"><span style="color: rgb(0, 0, 0);">*Indicate and describe in detail which type of service you are in need of. </span></span></span></span></b></p>
    <p>&nbsp;</p>
    <p><span style="color: rgb(128, 0, 128);"><b><span style="font-family: Verdana;"><input type="checkbox" name="" />Pick-Up/Drop-off Services</span></b></span></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-family: Verdana;"><input type="checkbox" name="" />Shopping Services</span></span></b></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-family: Verdana;"><input type="checkbox" name="" />Sitting Services</span></span></b></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-family: Verdana;"><input type="checkbox" name="" />Event Planning Services</span></span></b></p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-family: Verdana;"><input type="checkbox" name="" />Home Services</span></span></b></p>
    <p>&nbsp;</p>
    <p><b><span style="color: rgb(128, 0, 128);"><span style="font-family: Verdana;"><textarea rows="10" cols="40" name=""></textarea></span></span></b></p>
</form>
<p><b><b><br />
</b></b></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
Logged
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #12 on: June 30, 2010, 07:08:43 PM »

if you follow the same principles it will work, just make sure that if you have an input on your form that you have a accompaning process for that in your process file..  it does no good to have inputs that you do nothing with..

also learn some css (its easy) or use a table if you need to and take all those spaces out, its pretty hacky when you use all those spaces, not only that but it makes it hard to read lol

i would prefer to see all the colors and design styles items in a css file rather than for each line like that...  but we have all been there and you will learn over time.

finally use POST  not GET    and make sure on every input that you close it with />  i see  you have done that and thats great, keep that up, its better to start with the right habbits.. your one step closer to writing something that is w3c validated lol 
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: