www.webdeveloper.com
Page 1 of 4 123 ... LastLast
Results 1 to 15 of 47

Thread: New to PHP

  1. #1
    Join Date
    Sep 2012
    Posts
    48

    New to PHP

    I built this site, and I'm not sure if my form is working. I have a PHP file called index.php, but I'm not sure it's linked to the site. Plus my comment box and send button will not center in the page. Can someone help me please?

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

  2. #2
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    It looks like you have set each one of your .html pages up as a site built with out php.

    Your index.php file will default to your main page. it needs to sit in your main directory.

    then you can <?php include 'header.php'; ?> footer.php nav.php etc.

    your url is showing up as html so its the server is not rendering the php.


    change the name of your main directory file to index.php and code that as your home page.

  3. #3
    Join Date
    Sep 2012
    Posts
    48
    I only use .PHP on one page. The following page.

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

  4. #4
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    try this to align the box and submit button center.

    Code:
    <center>
    <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>
    </center
    </table>
    
    </form>

  5. #5
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    why are you using .php on that page?


    or do you mean the submit button action goes to a .php file ???

  6. #6
    Join Date
    Sep 2012
    Posts
    48
    For the form. So people can fill it out and email it to the person. You mean theres an easyer way

  7. #7
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    Copy Nd paste your php code for me to see

  8. #8
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    The name and id of each for field must match the php variable if not the for submit button wont work

  9. #9
    Join Date
    Sep 2012
    Posts
    48
    <?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['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

    $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";


    // 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.

    <?php
    }
    die();
    ?>

  10. #10
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    And the form

  11. #11
    Join Date
    Sep 2012
    Posts
    48
    <!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>

  12. #12
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    Give me a bit

  13. #13
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    would you like something that looks like this?

    http://www.nichodiaz.com/contacts.php

  14. #14
    Join Date
    Sep 2012
    Posts
    48
    The layout has to be like what I have now.

  15. #15
    Join Date
    Aug 2012
    Location
    TX
    Posts
    293
    what is the name of your php file exactly

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 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