Results 1 to 7 of 7

Thread: PHP Form script error

  1. #1
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Form script error

    Hello all,

    I am new to web design and currently creating a website for my graphic design company. I am stuck on a form I have put together. The php file which attaches isn't working properly, it loads as a blank page, whether the info is correct in the completed form or not. Please could anyone review it and let me know where I may have gone wrong
    PHP Code:
       <?php
    if(isset($_POST['email'])) {
        
        
    // EDIT THE 2 LINES BELOW AS REQUIRED
        
    $email_to "hello@creativeiscaboodle.co.uk";
        
    $email_subject "Job Sheet from Creative Caboodle Website";

        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['Company_Name']) ||
            !isset(
    $_POST['Contact_Name']) ||
            !isset(
    $_POST['Email_Address'])) {
            
    died('We are sorry, but there appears to be a problem with the form you submitted.');       
     
        }
        
        
    $Company_Name $_POST['Company_Name']; // required
        
    $Contact_Name $_POST['Contact_Name']; // required
        
    $Phone_Number $_POST['Phone_Number']; // not required
        
    $Email_Address $_POST['Email_Address']; // required
        
    $Website $_POST['Website']; // not required
        
    $Address $_POST['Address']; // not required
        
    $Tell_Us_About_Your_Company $_POST['Tell_Us_About_Your_Company']; // not required
        
    $Target_Audience $_POST['Target_Audience']; // not required
        
    $Existing_Identity_And_Guidelines $_POST['Existing_Identity_And_Guidelines']; // not required
        
    $Design_Needs$_POST['Design_Needs']; // not required
        
    $Printing_Requirements $_POST['Printing_Requirements']; // not required
        
    $Supply_Of_Images $_POST['Supply_Of_Images']; // not required
        
    $Additional_Info $_POST['Additional_Info']; // not required
        
    $Websites_Like $_POST['Websites_Like']; // not required    
        
        
    $error_message "";
        
    $email_exp '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
      if(!
    preg_match($email_exp,$Email_Address)) {
        
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
      }
        
    $string_exp "/^[A-Za-z .'-]+$/";
      if(!
    preg_match($string_exp,$Company_Name)) {
        
    $error_message .= 'The Company Name you entered does not appear to be valid.<br />';
      }
      if(!
    preg_match($string_exp,$Contact_Name)) {
        
    $error_message .= 'The Contact Name you entered does 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 .= "Company Name: ".clean_string($Company_Name)."\n";
        
    $email_message .= "Contact Name: ".clean_string($Contact_Name)."\n";
        
    $email_message .= "Phone Number: ".clean_string($Phone_Number)."\n";
        
    $email_message .= "Email Address: ".clean_string($Email_Address)."\n";
        
    $email_message .= "Website: ".clean_string($Website)."\n";
        
    $email_message .= "Address: ".clean_string($Address)."\n";
        
    $email_message .= "Please tell us about your company, including a brief summary of your products / services: ".clean_string($Tell_Us_About_Your_Company)."\n";
        
    $email_message .= "What’s your target audience: ".clean_string($Target_Audience)."\n";
        
    $email_message .= "Do you have any existing corporate identity / guidelines (please include details of any colours, fonts, logo’s etc): ".clean_string($Existing_Identity_And_Guidelines)."\n";
        
    $email_message .= "What are you looking for i.e. business card, logo design, website design and build, leaflet etc (please be as detailed as possible): ".clean_string($Design_Needs)."\n";
        
    $email_message .= "If your project is for print, please provide details of any specific requirements, such as gloss finish, qty etc: ".clean_string($Printing_Requirements)."\n";
        
    $email_message .= "Will you be supplying any relevant imagery required for the project or do you want us to source this: ".clean_string($Supply_Of_Images)."\n";
        
    $email_message .= "Is there anything else we need to know such as deadlines, budgets, design concepts etc: ".clean_string($Additional_Info)."\n";
        
    $email_message .= "If You would like a website, please provide website address of websites you like the look of and what you like about them: ".clean_string($Websites_Like)."\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);
    ?>


    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet' type='text/css'>
    <link href="css/job_stylesheet.css" rel="stylesheet" type="text/css" />
       

    </head>

    <body onload="initialize()">
    <div id="headerwrapper">
    <div id="header">
    <div id="social">
    <a href="http://www.facebook.com/creativeiscaboodle"> <img src="images/facebook.png" width="25" height="27" alt="Creative Caboodle Facebook" onmouseover="this.src='images/facebook1.png';" onmouseout="this.src='images/facebook.png';"/></a>
    <a href="http://uk.linkedin.com/in/creativecaboodle/"> <img src="images/linkedin.png" width="25" height="27" alt="Creative Caboodle Linkedin" onmouseover="this.src='images/linkedin1.png';" onmouseout="this.src='images/linkedin.png';"/></a></br>

    <class="toplinks">
    <a href = "http://system.creativeiscaboodle.co.uk">Client Log In</a></span></p>
    </class>

    </div>

    <a href="http://www.creativeiscaboodle.co.uk"> <img src="images/logo.png" alt="Creative Caboodle Logo" /></a>
    <div id="menu">
    <ul>
    <li class="menu1"> <a href="http://www.creativeiscaboodle.co.uk/index.html">Home</a></li>
    <li class="menu2"> <a href="http://www.creativeiscaboodle.co.uk/profile.html">Profile</a></li>
    <li class="menu3"> <a href="http://www.creativeiscaboodle.co.uk/work.html">Work</a></li>
    <li class="menu4"> <a href="http://www.creativeiscaboodle.co.uk/services.html">Services</a></li>
    <li class="menu5"> <a href="http://www.creativeiscaboodle.co.uk/unwind.html">Unwind</a></li>
    <li class="menu6"> <a href="http://www.creativeiscaboodle.co.uk/connect.html">Connect</a></li>
    <li class="menu7"> <a href="http://www.creativeiscaboodle.co.uk/dashboard.html">Dashboard</a></li>
    </ul>
    </div>
    </div>
    </div>
    <div class="clear"></div>
    </div>

    <div id="wrapper">
    </br>
    </br>
    </br>
    <h1>
    <center>Thank you, one of team will be in touch shortly</center>
    </h1>

    </div>

    <div id="footerwrapper">
    <div id="footer">

    <div class="footertitle">
    Creative Caboodle
    </div>


    <div class="copyright">
    <a href="http://www.creativeiscaboodle.co.uk/privacy_policy.html">Privacy Policy</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.creativeiscaboodle.co.uk/terms_and_conditions.html">Terms & Conditions</a>&nbsp;&nbsp;|&nbsp;&nbsp;Copyright &copy; Creative Caboodle 2012-2014&nbsp;&nbsp;|&nbsp;&nbsp;All rights resevered
    </div>

    </div>
    </div>

    </body>
    </html>


    <?php
     
    }
     
    ?>
    Last edited by creativecaboodle; 02-24-2014 at 09:10 AM.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    PHP Code:
    if(isset($_POST['email'])) { 
        
    //* . . . 
    Your code only runs if there is a POST parameter named "email". Have you double-checked your form to make sure this field exists?

  3. #3
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Not sure what this should look like sorry. Would this be in the form which the user completed and if so do you know how t should look so I can check? Sorry, still learning. Thanks

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Yes, the form that you fill out and submit to this php script. Use (right click) -> "View Source" to see the HTML markup. You're looking for two things, at this point: something like
    HTML Code:
    <form method="POST">
        . . .
    and, inside that form, something like
    HTML Code:
    <input name="email">

  5. #5
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have had a look at the form itself and can't see what I need to change sorry. Could you look at the below for me and point me in the right direction?

    HTML Code:
    <form name="contactform" method="post" action="send_job_sheet.php">
    <table width="950" border="0" cellspacing="0" cellpadding="0">
      <tr height="40">
        <td valign="top" align="left" class="contactright"><label for="Company_Name">Company name</label></td>
        <td valign="top" align="left"><input  type="text" name="Company_Name" maxlength="56" size="56"></td>
        <td valign="top" align="left" class="contactright"><label for="Contact_Name">Contact name</label></td>
        <td valign="top" align="left"><input  type="text" name="Contact_Name" maxlength="56" size="56"></td>
      </tr>
      <tr height="40">
        <td valign="top" align="left" class="contactright"><label for="Phone_Number">Phone Number</label></td>
        <td valign="top" align="left"><input  type="text" name="Phone_Number" maxlength="56" size="56"></td>
        <td valign="top" align="left" class="contactright"><label for="Email_Address">Email Address</label></td>
        <td valign="top" align="left"><input  type="text" name="Email_Address" maxlength="56" size="56"></td>
      </tr>
      <tr height="40">
        <td valign="top" align="left" class="contactright"><label for="Website">Website</label></td>
        <td valign="top" align="left"><input  type="text" name="Website" maxlength="56" size="56"></td>
        <td valign="top" align="left">&nbsp;</td>
        <td valign="top" align="left">&nbsp;</td>
      </tr>
      <tr height="40">
        <td valign="top" align="left" class="contactright"><label for="Address">Address<label for="first_name"></td>
        <td colspan="3" align="left" valign="top"><input  type="text" name="Address" maxlength="135" size="135"></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Tell_Us_About_Your_Company">Please tell us about your company, including a brief summary of your products / services</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Tell_Us_About_Your_Company" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Target_Audience">What’s your target audience</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Target_Audience" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Existing_Identity_And_Guidelines">Do you have any existing corporate identity / guidelines (please include details of any colours, fonts, logo’s etc)</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Existing_Identity_And_Guidelines" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Design_Needs">What are you looking for i.e. business card, logo design, website design and build, leaflet etc (please be as detailed as possible)</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Design_Needs" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Printing_Requirements">If your project is for print, please provide details of any specific requirements, such as gloss finish, qty etc</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Printing_Requirements" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Supply_Of_Images">Will you be supplying any relevant imagery required for the project or do you want us to source this</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Supply_Of_Images" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Additional_Info">Is there anything else we need to know such as deadlines, budgets, design concepts etc</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Additional_Info" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
          <tr height="60">
        <td colspan="4" align="left" valign="bottom" class="contactright"><label for="Websites_Like">If You would like a website, please provide website address of websites you like the look of and what you like about them</label></td>
        </tr>
      <tr height="40">
        <td colspan="4" align="left" valign="top"><textarea name="Websites_Like" maxlength="10000" cols="152" rows="6"></textarea></td>
        </tr>
      <tr height="60">
        <td colspan="4" align="left" valign="bottom"><input type="image" name="submit" border="0" src="images/submit.png" onmouseover="javascript:this.src='images/submithover.png';" onmouseout="javascript:this.src='images/submit.png';"> </td>
        </tr>
    </table>
    </form>
    Last edited by keyboard; 02-22-2014 at 09:35 PM. Reason: Format: Html Tags [html][/html]

  6. #6
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No worries, have just figured it out. Thanks for your help, appreciate it.

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Sure thing.

    If your question has been answered, please mark your thread "resolved":
    • On your original post (post #1), click [edit], then click [go advanced].
    • In the "thread prefix" box, select "Resolved".
    • Click [save changes].

Similar Threads

  1. Replies: 2
    Last Post: 05-06-2011, 08:24 AM
  2. Replies: 0
    Last Post: 06-09-2009, 08:11 AM
  3. Customize the Error Object in JavaScript (Error Handler Script)
    By hari.gomatum in forum Submit a DHTML or CSS code
    Replies: 1
    Last Post: 12-13-2007, 06:56 AM
  4. form error please help
    By ashuraj2163@yahoo.co.in in forum JavaScript
    Replies: 2
    Last Post: 09-29-2005, 05:24 PM
  5. Script: Form field Limiter (Error found)
    By Stahlratte in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 12-10-2004, 03:18 PM

Bookmarks

Posting Permissions

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