Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14

Thread: PHP Newb

  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question PHP Newb

    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


  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,511
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    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.?

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    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:
    Code:
    <!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>
    Last edited by oracleguy; 10-21-2009 at 11:47 PM. Reason: added code tags

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    What problem are you having? "I have tried and tried and tried" isn't a very useful problem description.
    Are you a Help Vampire?

  • #5
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tomws View Post
    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.

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?

  • #7
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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">

  • #8
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?

  • #9
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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."

  • #10
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?

  • #11
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,511
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    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.

  • #12
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by timan View Post
    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.
    OracleGuy

  • #13
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Regarding Date Difference

    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

  • #14
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    @cool89: That post is completely unrelated to the thread. Start a new thread to get an answer.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •