Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

How do I indent php to display code in order to get help

$
0
0

My code isn't working and I have put it into notepad++ and using a php error checker.

I want to put the code on here for help but know that you like it presented in a certain way to make life easier for all concerend. 

 

How do I indent the code properly on here?  Ideally I don't want the form submitted unless certain fields are filled in.  A pop up box which says please fill in your ......     .

 

<?php
 
if(isset($_POST['email'])) {
 
// EDIT THE 2 LINES BELOW AS REQUIRED
     $email_to = "xxxxx@xxxxxxx";
    $email_subject = "Your email subject line";
 
    function died($error) {
{
// Does this field have a value?
    if (empty($_REQUEST[$fieldName]))
    {
        echo 'Please go back and fill out ' . $fieldName . "<br>\n";
// validation expected data exists
     if(empty($_POST['first_name']) ||
        empty($_POST['last_name']) ||
        empty($_POST['email']) ||
        empty($_POST['telephone']) ||
       !isset($_POST['comments'])) {
 
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
     }
 
     if ((!first_name) || (!second_name)) {
    $errorMsg = 'Please make sure you have filled in the required fields:<br /><br />';
    if (!$first_name) {
    $errorMsg = 'Please fill in your First Name<br />';
    }
    if (!$seond_name) {
    $errorMsg = 'Please fill in your Second Name<br />';
    }
    if (!$mobile_number) {
    $errorMsg = 'Please fill in your contact number<br />';
    }
    if (!$email) {
    $errorMsg = 'Please fill in your email address<br />';
    }
    }
 
  //strip lashes
      $first_name = stripslashes($name);
    $second_name = stripslashes($second_name);
    $phone = stripslashes($phone);
    $email = stripslashes($email);
//clean 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);
 


Viewing all articles
Browse latest Browse all 13200

Trending Articles