www.webdeveloper.com
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 47

Thread: New to PHP

  1. #16
    Join Date
    Sep 2012
    Posts
    48
    index.php

  2. #17
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ok your form is submitting fine... you should have an email. verify you have it.

    the problem your going to have is making the check boxes show up

  3. #18
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    i ave it working... im fixing the check boxes for you. the reason it was not submitting is cause you didnt add the check box names to the php isset.

    give me 5 more minutes

  4. #19
    Join Date
    Sep 2012
    Posts
    48
    Thanks I appreciate all your help

  5. #20
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    paste this code in to your html file

    Code:
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Healing Axis - Home</title>
    <meta name="description" content="Free Web tutorials">
    <meta name="keywords" content="HTML,CSS,XML,JavaScript">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    </head>
    
    <body>
    
    <div class="header">
    <h2>Healing Axis</h2>
    </div>
    
    <div class="menu">
    <ul class="clearfix">
    <li><a href="index.html">Home</a></li>
    <li><a href="about.html">About</a></li>
    <li>
    <a href="#">Services</a>
    <ul>
    <li><a href="areas.html">Areas of Focus</a></li>
    <li><a href="practical.html">Practical Concerns</a></li>
    </ul>
    </li>
    <li><a href="blog.html">Blog</a></li>
    <li><a href="booking.html">Booking</a></li>
    <li><a href="contact.html">Contact / Hours</a></li>
    </ul>
    </div>
    
    <div class="content">
    
    <h4>Hello, how may we be of assistance to you? <br> To make an apointment, fill in the form below and send it back to us.</h4>
    
    
    <form name="htmlform" method="post" action="html_form_send.php">
    <table width="400" align="center">
    <td width="268"></tr>
    <tr>
    <td valign="top">
    <label for="first_name">First Name *</label>
    </td>
    <td width="212" 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>
    
    
    <td valign="top">
    </td>
    </tr> 
    
    <td valign="top">
    </td>
    </tr> 
    
    <table width="405" border="0" align="center">
    <tr>
    <td> <input type="checkbox" name="friut[]" value="Addictions" />Addictions</td>
    <td><input type="checkbox" name="friut[]" value="Emotions" /> Emotions </td>
    </tr>
    <tr>
    <td> <input type="checkbox" name="friut[]" value="Phobias and Fears" /> Phobias and Fears </td>
    <td> <input type="checkbox" name="friut[]" value="Eating Disorders" /> Eating Disorders </td>
    </tr>
    <tr>
    <td><input type="checkbox" name="friut[]" value="Relationships" /> Relationships</td>
    <td> <input type="checkbox" name="friut[]" value="Sexual Concerns" /> Sexual Concerns </td>
    </tr>
    </table>
    
    <br/>
    
    
    
    
    
    <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"><br/><br/>
    <input type="submit" value="Submit"></td>
    </tr>
    
    </table>
    
    </form>
    
    
    
    
    
    <div class="footer">Website designed by<a href="http://www.cjwebconsulting.com" target="_blank"> CJ Web Consulting</a></div>
    
    
    </div>
    
    </body>
    </html>
    And copy and paste this code in to your php file. and your all set
    Code:
    <?php
    if(isset($_POST['email'])) {
    
    // CHANGE THE TWO LINES BELOW
    $email_to = "conquer@mts.net";
    
    $email_subject = "conquer@mts.net";
    
    
    function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
    }
    
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
    !isset($_POST['last_name']) ||
    !isset($_POST['email']) ||
    !isset($_POST['telephone']) ||
    !isset($_POST['friut']) ||
    !isset($_POST['comments'])) {
    died('We are sorry, but there appears to be a problem with the form you 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
    
    foreach($_POST['friut'] as $value) {
    $check_msg .= "Problems $value\n";
    }
    
    
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
    }
    $string_exp = "/^[A-Za-z .'-]+$/";
    if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
    }
    if(!preg_match($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 />';
    }
    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";
    $email_message .= " ".clean_string($check_msg)."\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); 
    ?>
    
    <!-- place your own success html below -->
    
    Thank you for contacting us. We will be in touch with you very soon.<br /><br />
    <a href="index.php">Please Click Here To Return Home</a>
    
    <?php
    }
    die();
    ?>
    Please let me know this worked for you. I added a link after submit to take you back to the home page too.

  6. #21
    Join Date
    Sep 2012
    Posts
    48
    Tell me if you get an error screen. Or do I have to put my php file in a sub folder.

    http://www.cjwebconsulting.com/bonnie/booking.html

  7. #22
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    you need to put the file where ever u want it. and the reference it in the action field at the top of your form on the html page

    so if it was in the same file as the html file you would just put the name <form name="htmlform" method="post" action="html_form_send.php">

    but if it was in a file called actions for example.. it would be like this <form name="htmlform" method="post" action="action/html_form_send.php">
    Last edited by Nicholas Diaz; 05-08-2013 at 10:38 PM.

  8. #23
    Join Date
    Sep 2012
    Posts
    48
    What do you mean by reference it?

  9. #24
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    do you have the two files in the same folder? if not what folder do you have the php file in and what folder do you have the html form in?

  10. #25
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    to locate a file in html you can find the directory by ../ to go back a directory. or you can type the folder then the file like this... folder/something.php

    or to go back ../folder/something.php

  11. #26
    Join Date
    Sep 2012
    Posts
    48
    I have all the html files and the one php file in one folder. I have one subfolder that has my CSS file.

  12. #27
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    then copy and paste my code exactly the way i did.

    and then look at the top of the form and make sure the spelling is right on the php file.

  13. #28
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    and if you copy and paste this over the section of your form with the comment box and the submit button it will center it all for you


    Code:
     <tr>
    <td valign="top" >
    <center>
    <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"><br/><br/>
    <input type="submit" value="Submit"></td>
    </center>
    </tr>
    
    </table>
    
    </form>

  14. #29
    Join Date
    Sep 2012
    Posts
    48
    Did you get a error page as well?

  15. #30
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    ya from your site. its your file structure. or spelling or maybe a " missing. could be anything. if you want email me a zipfile of your site and ill have it working 100 percent in less than five minutes. nichodiaz@nichodiaz.com


    but i know it works... cause i just spent two hours going through your code line by line and creating the check box array. i have 17 emails from testing the form to my email box

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles