...

View Full Version : PHP Newb



timan
10-21-2009, 03:40 AM
I am feeling like a complete n00b atm. I have made a website, using .cfm, and have set up my contact page for a php mailer file. But I am having troubles coding it. I have tried and tried and tried with no prevail. I need it to email me up hitting submit with the following fields:

First Name:

Last Name:

Address Street 1:

Address Street 2:

City:

Zip Code:

State:

Daytime Phone:

Evening Phone:

Email:

Comments

any help is much appreciated. Oh and the "state" field is a drop down menu. Thanks again in advance

:confused::confused::confused::confused::confused:

mlseim
10-21-2009, 04:24 AM
You have to at least make the HTML form for us.
There are many examples you can find (using Google).

Then some other decisions, like ... anti-spam? captcha, or some other thing?
Form validation, like proper email format, required fields, etc.?

timan
10-21-2009, 02:02 PM
You have to at least make the HTML form for us.
There are many examples you can find (using Google).

Then some other decisions, like ... anti-spam? captcha, or some other thing?
Form validation, like proper email format, required fields, etc.?

I hope this is what you mean, but my page coding atm is:


<!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"><!-- InstanceBegin template="/Templates/main-2-col.dwt.cfm" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Contact </title>
<meta name="keywords" content="em" />
<meta name="description" content="Consultants" />
<meta name="robots" content="index,follow" />
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<link href="styles/styles-index.css" rel="stylesheet" type="text/css" />
<link href="styles/styles-page-col-table.css" rel="stylesheet" type="text/css" />
<link href="styles/styles-page-mobile.css" rel="stylesheet" media="handheld" type="text/css" />
<script type="text/javascript" src="/CFIDE/scripts/cfform.js"></script>

<script type="text/javascript" src="/CFIDE/scripts/masks.js"></script>
<script type="text/javascript">
<!--
function _CF_checkCFForm_1(_CF_this)
{
//reset on submit
_CF_error_exists = false;
_CF_error_messages = new Array();
_CF_error_fields = new Object();
_CF_FirstErrorField = null;

//form element Name required check
if( !_CF_hasValue(_CF_this['Name'], "TEXT", false ) )
{
_CF_onError(_CF_this, "Name", _CF_this['Name'].value, "Please enter your name.");
_CF_error_exists = true;
}

//form element Phone required check
if( !_CF_hasValue(_CF_this['Phone'], "TEXT", false ) )
{
_CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Please enter your phone number.");
_CF_error_exists = true;
}

//form element Email required check
if( !_CF_hasValue(_CF_this['Email'], "TEXT", false ) )
{
_CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please enter your email.");
_CF_error_exists = true;
}

//form element Answer required check
if( _CF_hasValue(_CF_this['Answer'], "TEXT", false ) )
{
//form element Answer 'INTEGER' validation checks
if (!_CF_checkinteger(_CF_this['Answer'].value, true))
{
_CF_onError(_CF_this, "Answer", _CF_this['Answer'].value, "Please enter the answer.");
_CF_error_exists = true;
}

}else {
_CF_onError(_CF_this, "Answer", _CF_this['Answer'].value, "Please enter the answer.");
_CF_error_exists = true;
}


//display error messages and return success
if( _CF_error_exists )
{
if( _CF_error_messages.length > 0 )
{
// show alert() message
_CF_onErrorAlert(_CF_error_messages);
// set focus to first form error, if the field supports js focus().
if( _CF_this[_CF_FirstErrorField].type == "text" )
{ _CF_this[_CF_FirstErrorField].focus(); }

}
return false;
}else {
return true;
}
}
//-->
</script>
</head>

<body><a name="Top" id="Top"></a>
<div id="masthead"></div>
<div id="topnav"> <ul>
<li><a href="index.cfm">home</a></li>
<li><a href="philosophy-mission.cfm">PHILOSOPHY & MISSION</a></li>

<li><a href="services.cfm">SERVICES</a></li>
<li><a href="contact.cfm">CONTACT</a></li>
<li><a href="about-us.cfm">ABOUT US</a> </li>
<li><a href="index.cfm">HOME</a></li
</ul>
</div>
<div id="contentouter">
<div id="content"><!-- InstanceBeginEditable name="body" -->
<div id="middlecontent">

<h1>Contact Us</h1>
<p>Phone: ###-###-####</p>
<p>Postal: </p>
<hr />
<h2>Information Request Form </h2>
<div id="form">
<table width="90%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td>
<p align="center">Please complete the fields below and we will respond to your inquiry within 48 hours.</p>
</td>
</tr>
</table>
<p></p>
<table width="90%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td>
<p align="right">First Name:</p>
</td>
<td>
<p><input type="text" name="First Name" /></p>
</td>
</tr>

<tr>
<td>
<p align="right">Last Name:</p>
</td>
<td>
<p><input type="text" name="Last Name" /></p>
</td>
</tr>

<tr>
<td>
<p align="right">Address Street 1:</p>
</td>
<td>
<p><input type="text" name="Address Street 1" size="30" /></p>
</td>
</tr>

<tr>
<td>
<p align="right">Address Street 2:</p>
</td>
<td>
<p><input type="text" name="Address Street 2" size="30" /></p>
</td>
</tr>

<tr>
<td>
<p align="right">City:</p>
</td>
<td>
<p><input type="text" name="City" /></p>
</td>
</tr>

<tr>
<td>
<p align="right">Zip Code:</p>
</td>
<td>
<p><input type="text" name="Zip Code" size="5" maxlength="5" /></p>
</td>
</tr>

<tr>
<td>
<p align="right">State:</p>
</td>
<td>
<p><select name="State">
<option value="AL">AL</option>
<option value="AK">AK</option>

<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>

<option value="DC">DC</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>

<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>

<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>

<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>

<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>

<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>

<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>

<option value="WY">WY</option>
</select></p>
</td>
</tr>
<tr>
<td>
<p align="right">Daytime Phone:</p>
</td>

<td>
<p><input type="text" name="Daytime Phone" /></p>
</td>
</tr>
<tr>
<td>
<p align="right">Evening Phone:</p>
</td>

<td>
<p><input type="text" name="Evening Phone" /></p>
</td>
</tr>
<tr>
<td>
<p align="right">Email:</p>
</td>

<td>
<p><input type="text" name="Email" /></p>
</td>
</tr>
<tr>
<td>
<p align="right">Comments:</p>
</td>

<td>
<p><textarea name="Comments" cols="38">Enter comments here!</textarea></p>
</td>
</tr>
</table>
<p><input type="submit" /><input type="reset" /></p>
</div>
</div>

<div id="rightcontent">
<h2>Located where you and your business are.</h2>
</div>
<!-- InstanceEndEditable --></div>
<div id="contentpush"></div>
</div>
<div id="footer">
<p><a href="#Top">Return to Top</a></p>

<p><a href="index.cfm">home</a> | <a href="philosophy-mission.cfm">Philosophy &amp; Mission</a> |
<a href="services.cfm">Services</a> | <a href="contact.cfm">Contact</a> | <a href="about-us.cfm">About Us</a> | <a href="index.cfm">Home</a></p>

</div>

</body>
</html>

tomws
10-21-2009, 07:29 PM
What problem are you having? "I have tried and tried and tried" isn't a very useful problem description.

timan
10-21-2009, 07:48 PM
What problem are you having? "I have tried and tried and tried" isn't a very useful problem description.

I am having trouble coding a php form to have the submit button email the form upon being pressed. I have never coded php before and have googled it and tried some examples but they all failed horribly.

tomws
10-21-2009, 08:38 PM
Well, I don't know if the ColdFusion coding has anything to do with it, but you don't have a form tag (with action) in your code, so that's going to be a good place to start.

There are lots of tutorials available on PHP form handling and many of them discuss mailing form results. There's no form handling code in your post, so there's no way to know what you've tried or what's broken.

timan
10-21-2009, 08:57 PM
Well yes I do have form handling it in my code. I do not know why it did not post in the code when I pasted it. It is located below my

<body> tag and I have it as

<form action="contact.cfm" method="mailer.php">

tomws
10-21-2009, 09:08 PM
The form tag's method can be either 'get' or 'post' (should be 'post' in this context). The action is where the form's data should be sent for handling. Assuming the page source you posted earlier is actually contact.cfm, it's sending data to itself where, no, there is no form handling code.

You should probably check out some tutorials again so you can understand the basics of how PHP form handling/processing works. I recommend a Google search on "php form handling processing tutorial". Don't just look for code to copy and paste. Try to understand how the process works.

timan
10-21-2009, 09:23 PM
Well I wasn't just looking at codes on google or tutorials to "copy and paste." I actually spent a while looking at them and was having a difficult time understanding it. Hence why I resorted to here. I was coming here for advice not asking yourself or anyone else to make me a code so I can once again "copy and paste."

tomws
10-21-2009, 09:46 PM
Fair enough. My advice from my last post still stands. If you have a specific question on a problem, then someone will be able to provide an answer.

mlseim
10-21-2009, 11:45 PM
It's my fault ...

I told Timan to at least post the form so we could see it.
So he stepped-up to the plate and posted something ...
with a few things missing, but most of it is there.

I just got too busy to look at it today.

He then needs the PHP part of it (to send email).
I can't test what is posted though, as it has a bunch of Javascripting.

oracleguy
10-21-2009, 11:50 PM
I am feeling like a complete n00b atm. I have made a website, using .cfm, and have set up my contact page for a php mailer file.

Are you using ColdFusion or PHP? You say the pages are .cfm but you want to create a PHP script to email a form. Unless there is a really good reason, you should avoid mixing server side languages. If the site is already done using ColdFusion, you should stick to it.

cool89
10-22-2009, 02:04 PM
Date Difference
I have the following php statement in my view.ctp (cakephp)

<?php echo date("m/d/Y",strtotime($user['User']['tenure_date']));?></td>


But what I need to do is take this statement and get a difference of this date with current date and get the answer to be displayed in years and months for example 20years or 20years and 4 months in my view.ctp


PLEASE GUIDE ME IF YOU GUYS CAN

tomws
10-22-2009, 02:13 PM
@cool89: That post is completely unrelated to the thread. Start a new thread to get an answer.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum