Need help please. (PHP)

Discussion in 'Web Programming' started by T R 1 B A L, Dec 25, 2009.

Need help please. (PHP)
  1. Unread #1 - Dec 25, 2009 at 11:23 AM
  2. T R 1 B A L
    Joined:
    Jun 27, 2007
    Posts:
    2,726
    Referrals:
    1
    Sythe Gold:
    0

    T R 1 B A L Grand Master
    Retired Sectional Moderator

    Need help please. (PHP)

    okay here's my contact.php, and for some reason, when you don't input a field, in the HTML page it comes up with
    Code:
    $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content)) { echo 'Message sent!'; } else { echo 'ERROR!'; } } ?>
    PHP:
    <?php

    if(!$_POST) exit;

    $email $_POST['email'];


    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
        
    $error.="Invalid email address entered";
        
    $errors=1;
    }
    if(
    $errors==1) echo $error;
    else{
        
    $values = array ('name','email','message');
        
    $required = array('name','email','message');
         
        
    $your_email "########@hotmail.co.uk";
        
    $email_subject "New Message: ".$_POST['subject'];
        
    $email_content "new message:\n";
        
        foreach(
    $values as $key => $value){
          if(
    in_array($value,$required)){
            if (
    $key != 'subject' && $key != 'company') {
              if( empty(
    $_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
            }
            
    $email_content .= $value.': '.$_POST[$value]."\n";
          }
        }
         
        if(@
    mail($your_email,$email_subject,$email_content)) {
            echo 
    'Message sent!'
        } else {
            echo 
    'ERROR!';
        }
    }
    ?>
     
  3. Unread #2 - Jan 1, 2010 at 11:37 AM
  4. Rdogg999
    Joined:
    Jan 16, 2008
    Posts:
    215
    Referrals:
    0
    Sythe Gold:
    0

    Rdogg999 Active Member

    Need help please. (PHP)

    not sure, but try this:
    PHP:
    <?php

    if(!$_POST) exit;

    $email $_POST['email'];


    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
        
    $error.="Invalid email address entered";
        
    $errors=1;
    }
    if(
    $errors==1) echo $error;
    else{
        
    $values = array ('name','email','message');
        
    $required = array('name','email','message');
         
        
    $your_email "########@hotmail.co.uk";
        
    $email_subject "New Message: ".$_POST['subject'];
        
    $email_content "new message:\n";
        }
        foreach(
    $values as $key => $value){
          if(
    in_array($value,$required)){
            if (
    $key != 'subject' && $key != 'company') {
              if( empty(
    $_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
            }
            
    $email_content .= $value.': '.$_POST[$value]."\n";
          }
        }
         
        if(@
    mail($your_email,$email_subject,$email_content)) {
            echo 
    'Message sent!'
        } else {
            echo 
    'ERROR!';
        }
    }
    ?>
     
< Need help this is prob easy! | Help Me Build My Portfolio >

Users viewing this thread
1 guest


 
 
Adblock breaks this site