Jump to content

Search the Community

Showing results for tags 'submission'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 2 results

  1. Hi good people of w3, I'd been using the tutorials on this site a lot in an attempt to get the email enquiry form working for the website I've been putting together for the place I'm currently employed at. This isn't exactly my forte, I'm pretty decent when it comes to html but php is an animal I'm only just starting to become familiar with.I have an issue currently where particular parts of the form are required to be filled in, and I can successfully generate errors when this does not occur. However, the errors do not actually stop the email from being sent and hence we end up with incomplete enquiries on the other side when the form is not correctly filled in.If anyone could provide some advice as to a means to make the errors stop the email from being sent, that would be much appreciated. The relevant code is below. <?php// define variables and set to empty values$nameErr = $emailErr = $partErr = $phoneErr = "";$name = $email = $part = $comments = $model = $brand = $phone = $contact_method = $product = $breakdown = "";if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["phone"])) { $contact_methodErr = "Phone number is required"; } else { $phone = test_input($_POST["phone"]); } $contact_method = test_input($_POST["contact_method"]); $brand = test_input($_POST["brand"]); $product = test_input($_POST["product"]); $model = test_input($_POST["model"]); $breakdown = test_input($_POST["breakdown"]); if (empty($_POST["part"])) { $partErr = "Part number or description is required"; } else { $part = test_input($_POST["part"]); } $comments = test_input($_POST["comments"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;}// Function to validate against any email injection attemptsfunction IsInjected($str){ $injections = array('(n+)', '(r+)', '(t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; }} //Validate firstif(IsInjected($customer_email)){ echo "Bad email value!"; exit;} $email_from = 'sales@speedyspares.com';//<== update the email address $email_subject = "Online Enquiry"; $email_body = '<html><body>'; $email_body .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $email_body .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . $name = $_POST["name"] . "</td></tr>"; $email_body .= "<tr><td><strong>Email:</strong> </td><td>" . $email = $_POST["email"] . "</td></tr>"; $email_body .= "<tr><td><strong>Phone:</strong> </td><td>" . $phone = $_POST["phone"] . "</td></tr>"; $email_body .= "<tr><td><strong>Preferred Method of Contact:</strong> </td><td>" . $contact_method = $_POST[ "contact_method"] . "</td></tr>"; $email_body .= "<tr><td><strong>Brand:</strong> </td><td>" . $brand = $_POST["brand"] . "</td></tr>"; $email_body .= "<tr><td><strong>Product:</strong> </td><td>" . $product = $_POST["product"] . "</td></tr>"; $email_body .= "<tr><td><strong>Model:</strong> </td><td>" . $model = $_POST["model"] . "</td></tr>"; $email_body .= "<tr><td><strong>Breakdown Required:</strong> </td><td>" . $breakdown = $_POST["breakdown"] . "</td></tr>"; $email_body .= "<tr><td><strong>Part:</strong> </td><td>" . $part = $_POST["part"] . "</td></tr>"; $email_body .= "<tr><td><strong>Comments:</strong> </td><td>" . $comments = $_POST["comments"] . "</td></tr>"; $email_body .= "</table>"; $email_body .= "</body></html>"; $to = "sales@speedyspares.com";//<== update the email address $headers = "From: $email_from rn"; $headers .= "Reply-To: $email rn"; $headers .= "MIME-Version: 1.0rn"; $headers .= "Content-Type: text/htmlrn"; //Send the email! mail($to,$email_subject,$email_body,$headers); //done. redirect to thank-you page. header('Location: thankyou.html'); ?><form method="post" name="enquiry-form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <h6><strong><span class="redasterisk">*</span></strong>denotes a required field</h6> <h6>Name:<span class="error">* <?php echo $nameErr;?></span><br> <input name="name" type="text" size="50"> <br> E-mail:<span class="error">* <?php echo $emailErr;?></span><br> <input name="email" type="text" size="50"> <br> Phone:<span class="error">* <?php echo $phoneErr;?></span><br> <input name="phone" type="text" size="50"> <br /> Preferred Contact Method:<br /> <input type="radio" name="contact" value="email" /> Email <input type="radio" name="contact" value="phone" /> Phone <br /> Brand:<br> <select name="brand"> <option value="Sony">SONY</option> <option value="Sharp">SHARP</option> <option value="Hills">HILLS</option> <option value="Other">OTHER</option> </select><br /> Product:<br> <select name="product"> <option value="TV">TV/PROJECTOR</option> <option value="VIDEO">HOME VIDEO/DVD/BLU-RAY</option> <option value="AUDIO">HOME AUDIO/THEATRE SYSTEM</option> <option value="CAMERA">DIGITAL STILL CAMERA</option> <option value="CAMCORDER">VIDEO CAMERA/CAMCORDER</option> <option value="VAIO">PERSONAL COMPUTER (VAIO)</option> <option value="EREADER">eBOOK READER</option> <option value="PAUDIO">PERSONAL AUDIO</option> <option value="CAUDIO">CAR AUDIO</option> <option value="FRIDGE">REFRIDGERATOR</option> <option value="MICROWAVE">MICROWAVE</option> <option value="OTHER">OTHER</option> </select><br /> Model :<br /><em>(eg. KDL-46HX800)</em><br> <input type="text" name="model" size="50"> <br /> <input type="checkbox" name="breakdown" value="Yes" /> Request Breakdown<br /> Part number/description:<span class="error">* <?php echo $partErr;?></span><br /><em>(e.g. UWA-BR100 Wi-fi Adaptor)</em><br /> <input type="text" name="part" size="50"> <br> Comments:<br> <textarea name="comments" cols="50" rows="5">Please supply any additional information that may assist with your enquiry. (color/size/location etc.)</textarea> <br /> (Please do not use this form for submission of credit card information)</h6> <h5> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </h5> </form>
  2. I have created a checklist using HTML tables, however I want different people to be able to use the checklist and be able to come back to it and check things off as they are acquired or completed. I'm pretty sure I will need to use PHP and I know how to create a login page, and I think to be able to save the checkboxes for individual people I would use a PHP form but I'm not sure how to incorporate the table I have already created. Any help would be appreciated.
×
×
  • Create New...