Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Simple Submission Form in EZ-Pages

Simple Submission Form in EZ-Pages

Locked

Views: 2,344

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
23 Mar 2007, 11:17 PM
#1
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Simple Submission Form in EZ-Pages

Hey everyone,

I need to create an EZPage that has 3 fields and a submit button. All can easily be done in HTML form. I also have a very simple mail script that works perfectly. But... I can't get the EZPage to call the mail script properly.

I'm assuming this has something to do with not being able to use PHP in EZ-Pages.

Does anyone have an easy way to add a simple form in an EZPage?

I did see Dr. Bytes extremely informative how to for a complex template based form. My needs are just much much simpler...

Any advice would be appreciated.

Thanks in advance.

24 Mar 2007, 8:42 AM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

Are you simply looking to e-mail the results of the form to someone, or do you need the data to be written into the database?

24 Mar 2007, 9:22 AM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

You can try this... All four files reside in the same directory. This is NOT being used by us on zencart, so there is NO WARRANTY. You may need to modify the html headers (or remove them) if you strip the BODY code into other pages.

File One - contact.php

<?php

// ** This simple php script drives an input form included with this package
// ** You can change the FIELD NAMES if you wish - just ensure that whatever name you choose CORRESPONDS
// **   with the input names on "contact.html". The field names must be changed in SECTIONS 1, 2 and 3 below.
// **
// ** You can also ADD fields (see the commented out examples below)


// SECTION ONE
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "[email protected]"; //The email address to which you want the data to be sent.
$Subject = "SUBJECT OF EMAIL"; //Enter the desired SUBJECT for this email.
$FirstName = Trim(stripslashes($_POST['FirstName'])); 
$LastName = Trim(stripslashes($_POST['LastName'])); 
$Company = Trim(stripslashes($_POST['Company'])); 
$Country = Trim(stripslashes($_POST['Country'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Website = Trim(stripslashes($_POST['Website'])); 
$Comments = Trim(stripslashes($_POST['Comments'])); 
//$NewField = Trim(striplashes($_POST['NewField']));


// SECTION TWO
// validation (These set ALL fields as REQUIRED fields)
// To remove validation for any given field, comment it out - eg:
// if (Trim($EmailFrom)=="") $validationOK=false;
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($FirstName)=="") $validationOK=false;
if (Trim($LastName)=="") $validationOK=false;
if (Trim($Company)=="") $validationOK=false;
if (Trim($Country)=="") $validationOK=false;
if (Trim($Tel)=="") $validationOK=false;
if (Trim($Website)=="") $validationOK=false;
if (Trim($Comments)=="") $validationOK=false;
//if (Trim($NewField)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
  exit;
}

//SECTION THREE
// prepare email body text
$Body = "";
$Body .= "FirstName: ";
$Body .= $FirstName;
$Body .= "\n";
$Body .= "LastName: ";
$Body .= $LastName;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Website: ";
$Body .= $Website;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";
//$Body .= "NewField: ";
//$Body .= $NewField;
//$Body .= "\n";

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

// redirect to success page (or if ERROR, redirect to error page)
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

File Two - contact.html

<!--This is the html code for the INPUT form that is driven by "contact.php".
Place it between the BODY tags of your html page and put it in the same directory as "contact.php"
Remember, if you de-validate fields in the PHP file, remove the relative asterisks in the text below. -->

<span><h3>Contact Form</h3></span>
<p>Please complete the form and submit it to us.
    


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

<p>Your Email Address:* <br />
<input type="text" name="EmailFrom" size="45">
<br />First Name:* <br />
<input type="text" name="FirstName" size="45">
<br />Last Name:* <br />
<input type="text" name="LastName" size="45">
<br />Company:* <br />
<input type="text" name="Company" size="45">
<br />Country:* <br />
<input type="text" name="Country" size="45">
<br />Telephone (include area codes):* <br />
<input type="text" name="Tel" size="45">
<br />Website (if you have one):*<br />
<input type="text" name="Website" size="45">
<br />Comments / Questions:*<br />
<textarea name="Comments" rows="4" cols="50"></textarea>
<br /><input type="submit" name="submit" value="Submit">
</form>
<!-- if you ADD a NewField to this form, you need to modify contact.php too -->

File Three - thanks.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Thank You</title>
</head>

<body>

	<h1>Thank You</h1>
	<div>
	<h2> </h2>
	<h2>We have received your message</h2>     
    <p>We will respond soon.</p>
   	</div>


</body>
</html>

File Four - error.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Expires" content="-1" />
<title>Oops - there is an error</title>

</head>

<body>

	<h1>Oops! Something's not quite right...</h1>
	<div>
	<h2> </h2>
	<h2>We've encountered an error</h2>     
    <p>Perhaps you did not enter information into a "required" field, or there was a fault in the submission process.<br /><br />
	Please use the "Return to Previous Page" button and complete the form again. If you still experience problems, please contact us by telephone.<br />
    </p>
    <form>
      <div align="center"><center><p><input TYPE="button" VALUE="Return to previous page" onClick="history.go(-1)">  </p>
      </center></div>
    </form>
   	</div>
 
</body>
</html>
24 Mar 2007, 8:20 PM
#4
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

Thanks so much, Schoolboy.

I'm right in the middle of the Dr. Byte Band Signup Tutorial. But if that doesn't work perfect, this is the next strategy.

Thanks again, for all the time you put into it.

I will definitely keep you updated...

Adam.

29 Mar 2007, 8:28 PM
#5
pcdesigns avatar

pcdesigns

New Zenner

Join Date:
Feb 2007
Posts:
76
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

Hi, I wanted to try this but was not sure where to save the files. What folder should they be saved in?

9 Apr 2007, 8:56 PM
#6
divaboutiques avatar

divaboutiques

Zen Follower

Join Date:
Feb 2007
Location:
Worldwide Web
Posts:
191
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

I would liek to know this also:

Hi, I wanted to try this but was not sure where to save the files. What folder should they be saved in?

18 Apr 2007, 9:47 AM
#7
ditch avatar

ditch

New Zenner

Join Date:
Apr 2007
Posts:
13
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

Is it just me, or isa there an issue within the define pages editor which will not allow you to add a value'"submit" correctly.

I created a thread about this elsewhere, and seem to be talking to myself, so I'll try asking in here as well (I've relentlessly searched these forums).

When I paste in a contact from I made into the define pages editor, somehow, (when I go back in to edit the same page) the submit button has embedded itself into the define_pages_editor.php. I believe it has something to do with admin/includes/functions/html_output, but I'm not able to figure out hwat to modify. Basically, the text area is being comprimised by the form code, thusly 'submit' becomes part of the page.

This is very hard to explain, I undersatnd...hehe. However, I'm unsure of how else to do it. If anyone thinks a screenshot would help, I'd be more than happy to provide a series of them documenting this issue as it happens. However, I think there could be a fairly simple cure for it.

PS:

I even tried th above posted form, just to see if it would work. No go. I should also mention that right now, everything LOOKS fine from the user end, but were I to try and edit the page, clicking on 'save' would not even be an option...I would actually have to click the submit button which is now embedded. Whenthat is done, the textarea on the user end is suddenly full of footer code, and the page itself has no footer to speak of.

Haha...this sounds mildly psychotic.

Cheers

18 Apr 2007, 9:46 PM
#8
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: Simple Submission Form in EZ-Pages

Ditch,

I wish I could help solve it, but I've never run into that problem.

I might suggest using a code editor instead, though. I do everything with BBedit and Dreamweaver, and have not run into any problems creating the new forms.

I know there are some free ones out there for PC and Mac. And it would give you much more control over the code.

Anyway, that's my advice.

Hope all is good.