1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php Mail Form Question

Discussion in 'PHP' started by hmilesjr, Aug 9, 2005.

  1. #1
    Can someone look at this PHP Mail Form code and tell me what I have wrong? I am getting a parsing error on line 13.
    SEMrush

    <?
    $Title = $_REQUEST['Title'];
    $URL = $_REQUEST['URL'];
    $Category = $_REQUEST['Category'];
    $Description = $_REQUEST['Description'];
    $Name = $_REQUEST['Name'];
    $Email = $_REQUEST['Email'];
    $URLExchange = $_REQUEST['URLExchange'];

    if (!isset($_REQUEST['$Email'])) {
    header("Location : http://www.quoteforinsurancedirectory.com/free-listing.html");
    }
    elseif (empty($Title) || (empty($URL) || (empty($Description) || (empty($Name) || (empty($Email) || (empty($URLExchange)) {
    header ("Location : http://www.quoteforinsurancedirectory.com/form-error.html");
    }
    else {
    mail("admin@quoteforinsurance.com", "Link Exchange Request", "Title: $Title/nURL: $URL/nCategory: $Category/nDescription: $Description/nContact Name: $Name/nContact Email: $Email/nURL of Link Exchange: $URLExchange/n", "From: $Email" );
    header( "Location : http://www.quoteforinsurancedirectory.com/thank-you-request.html");
    }
    ?>
     
    hmilesjr, Aug 9, 2005 IP
    SEMrush
  2. UndiesHosting

    UndiesHosting Active Member

    Messages:
    219
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #2
    }
    elseif (empty($Title) || (empty($URL) || (empty($Description) || (empty($Name) || (empty($Email) || (empty($URLExchange)) {
    PHP:
    should be

    } elseif ( (empty($Title)) || (empty($URL)) || (empty($Description)) || (empty($Name)) || (empty($Email)) || (empty($URLExchange)) ){
    PHP:
    your parentheses are off...
     
    UndiesHosting, Aug 9, 2005 IP
  3. UndiesHosting

    UndiesHosting Active Member

    Messages:
    219
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #3
    edit:

    see above
     
    UndiesHosting, Aug 9, 2005 IP
  4. hmilesjr

    hmilesjr Active Member

    Messages:
    747
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #4
    So it should read as this?

    elseif
    (empty($Title)
    (empty($URL)
    (empty($Description)
    (empty($Name)
    (empty($Email)
    (empty($URLExchange)
    {
    header ("Location : http://www.quoteforinsurancedirectory.com/form-error.html");
    }
     
    hmilesjr, Aug 9, 2005 IP
  5. exaro

    exaro Peon

    Messages:
    615
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I just used ifs....for each one, it may take a few more lines of code, but it work's...like

    if($description == ''){
    echo "You need to fill in a description, go <a href=yourformpage.php>back</a>";
    }

    That way you can specify which was left blank...
     
    exaro, Aug 9, 2005 IP
  6. UndiesHosting

    UndiesHosting Active Member

    Messages:
    219
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #6
    For every ( you nee to have a respective ). You have 12 left parens between elseif and the bracket. You only have 6 right parens.


    
    (empty($Title))
    (empty($URL))
    (empty($Description))
    (empty($Name))
    (empty($Email))
    (empty($URLExchange))
    
    PHP:
    Would be a good start, but you also need an additional set of () around the entire if statement:

    
    elseif ( // open paren
    (empty($Title)) ||  // conditional 1
    (empty($URL)) ||  // conditional 2
    (empty($Description)) ||  // conditional 3
    (empty($Name)) ||  // conditional 4
    (empty($Email)) ||  // conditional 5
    (empty($URLExchange)) || // conditional 6
    ) // close paren for elseif statement
    {
    header ("Location : http://www.quoteforinsurancedirectory.com/form-error.html");
    }
    
    
    PHP:
    got it?

    edit: added ||s
     
    UndiesHosting, Aug 9, 2005 IP
  7. hmilesjr

    hmilesjr Active Member

    Messages:
    747
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #7
    I'm working on it. Just started trying to learn PHP today
     
    hmilesjr, Aug 9, 2005 IP
  8. hmilesjr

    hmilesjr Active Member

    Messages:
    747
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #8
    I have the paren fixed as per your instructions. The error I am getting is this:

    Parse error: parse error, unexpected '{' in /home/quotefor/public_html/add-link.php on line 13

    <?
    $Title = $_REQUEST['Title'];
    $URL = $_REQUEST['URL'];
    $Category = $_REQUEST['Category'];
    $Description = $_REQUEST['Description'];
    $Name = $_REQUEST['Name'];
    $Email = $_REQUEST['Email'];
    $URLExchange = $_REQUEST['URLExchange'];

    if (
    !isset($_REQUEST['$Email']
    )
    {
    header("Location : http://www.quoteforinsurancedirectory.com/free-listing.html");
    }
    elseif (
    (empty($Title))
    (empty($URL))
    (empty($Description))
    (empty($Name))
    (empty($Email))
    (empty($URLExchange))
    )
    {
    header ("Location : http://www.quoteforinsurancedirectory.com/form-error.html");
    }
    else {
    mail("admin@quoteforinsurance.com", "Link Exchange Request", "Title: $Title/nURL: $URL/nCategory: $Category/nDescription: $Description/nContact Name: $Name/nContact Email: $Email/nURL of Link Exchange: $URLExchange/n", "From: $Email" );
    header( "Location : http://www.quoteforinsurancedirectory.com/thank-you-request.html");
    }
    ?>
     
    hmilesjr, Aug 9, 2005 IP
  9. hmilesjr

    hmilesjr Active Member

    Messages:
    747
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #9
    The problem seems to be in the first part of the code:

    if (
    !isset($_REQUEST['$Email']
    )
    {
    header("Location : http://www.quoteforinsurancedirectory.com/free-listing.html");
    }
     
    hmilesjr, Aug 9, 2005 IP
  10. UndiesHosting

    UndiesHosting Active Member

    Messages:
    219
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #10
    Again you are missing a closing paren.

    if ( 
    !isset($_REQUEST['$Email']) // add the paren here
    ) 
    PHP:
     
    UndiesHosting, Aug 9, 2005 IP
  11. xeno

    xeno Peon

    Messages:
    788
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Did you get it worked out?
     
    xeno, Aug 11, 2005 IP