if condition error

Discussion in 'Perl' started by David Sudjiman, Mar 17, 2006.

  1. Hi,

    I'm using this perl script to get the information from a form and send
    it through email. The problem is when I do an email address validation.
    it seems it does not want to match it. For example, i give the real
    for mail_from it works. But if I give 123, the web page
    turns error 500 internal error. Please advice.



    #!/usr/bin/perl
    use strict;
    use warnings;

    use CGI;
    use CGI::pretty qw:)all);

    my $cgi = new CGI;

    my $rcpt_to = "abc\@abc\.com";
    my $mail_from = $cgi -> param('email');
    my $subject = $cgi -> param('milis');
    my $data = $cgi -> param('keterangan');
    my $request_method = $ENV{'REQUEST_METHOD'};
    my $remote_address = $ENV{'REMOTE_ADDR'};
    my $mail = "/usr/bin/mail -s $subject $rcpt_to";

    if (
    # $mail_from =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
    # $mail_from !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/)
    $mail_from == '123'
    ) {
    print "Email Error";
    }
    else {
    print $cgi -> header();
    print $cgi -> start_html("Title HERE!");
    print $cgi -> param('email'), "<br/>";
    print $cgi -> param('milis'), "<br/>";
    print $cgi -> param('keterangan'), "<br/>";
    print $cgi -> end_html();

    open (MAIL, "| $mail");
    print MAIL "$remote_address \n $data\n\n";
    close (MAIL);
    }
    David Sudjiman, Mar 17, 2006
    #1
    1. Advertising

  2. David Sudjiman wrote:
    [...]
    > validation. it seems it does not want to match it. For example, i
    > give the real for mail_from it works. But if I give 123,
    > the web page turns error 500 internal error. Please advice.


    Did you check "perldoc -q 500"?

    jue
    Jürgen Exner, Mar 17, 2006
    #2
    1. Advertising

  3. Jürgen Exner wrote:
    > Did you check "perldoc -q 500"?


    Just another cliche mistake. i need a bit a time of sleep. Check the
    error.log and found out that i forgot to put the header if the condition
    is true.

    "Did you decide to go see a movie?"

    thx
    ..dave

    http://www.davidsudjiman.info
    David Sudjiman, Mar 18, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -
    Replies:
    12
    Views:
    692
    Remon van Vliet
    Jun 15, 2005
  2. Derek Fountain

    Getting error condition from MySQLdb

    Derek Fountain, Nov 3, 2003, in forum: Python
    Replies:
    2
    Views:
    394
    Derek Fountain
    Nov 4, 2003
  3. Mark English
    Replies:
    0
    Views:
    288
    Mark English
    Jan 25, 2005
  4. Pete

    HashMap - error condition

    Pete, Jan 17, 2009, in forum: Java
    Replies:
    6
    Views:
    1,453
  5. Bill W.
    Replies:
    13
    Views:
    293
    Phillip Gawlowski
    May 9, 2011
Loading...

Share This Page