Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Continue] Contact form

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #26971
    Devilelites
    Member

    Hey,

    I dont understand PHP very much, so i used a script to make a contact form on my website. There’s a secure code, but if you just enter the code, you are able to send a blank message. If someone know what i can put into my "mailer.php" so you have to enter something in all the fields, it would be nice. You can find it here: http://www.graphicaldesign.wep.dk/kontakt.html
    It’s danish, but i hope someone can help. If you want the code from mailer.php just tell me.

    Greetings,
    Dev



    It has been continued. Read my latest post.

    #67158
    AshtonSanders
    Participant

    What script did you use to create this contact form?
    Did you just get some HTML code from somewhere?

    #67169
    Devilelites
    Member

    I searched for a script. It used PHP. Here’s the code if it helps:

    Mailer.php

    Code:





    E-Mail Sent


    Beskeden er sendt, tak for din henvendelse.

    Gå tilbage til forsiden?

    HTML

    Code:

    E-mail:

    Klik her og få en ny.


    Forkert sikkerhedskode


    Besked:



    #67173
    AshtonSanders
    Participant

    Here’;s the updated PHP code to check to make sure that the Subject, message and From fields all have at least one character in them… I didn’t make any sort of error coding, All errors will lead to the same page:

    For now you can just update the page to say "or you didn’t fill in a field…"

    It’s a simple start.

    Code:
    0 && strlen($subject) > 0 && strlen($from ) > 0 ){
    // if verification code was correct (and fields validate), send the message and show this page
    mail(“[email protected]”, ‘(GD) ‘.$subject, $_SERVER[‘REMOTE_ADDR’].”nn”.$message, “From: $from”);
    // delete the cookie so it cannot sent again by refreshing this page
    setcookie(‘tntcon’,”);
    } else if(isset($message) and $message!=””){
    // if verification code was incorrect then return to contact page and show error
    header(“Location:”.$_SERVER[‘HTTP_REFERER’].”?subject=$subject&from=$from&message=$message&wrong_code=true”);
    exit;
    } else {
    echo “Den indtastede sikkerhedskode var forkert. Gå tilbage og prøv igen.”;
    exit;
    }
    ?>




    E-Mail Sent


    Beskeden er sendt, tak for din henvendelse.

    Gå tilbage til forsiden?

    #67200
    Devilelites
    Member

    Thank you, it works. But there’s one problem. If you fill out every field, and it succes’s to sent, this shows up over my "You’ve sent it"-message:

    Warning: Cannot modify header information – headers already sent by (output started at F:HJEMMESIDERGRAPHICALDESIGNGRAPHICALDESIGN.WEP.DKmailer.php:1) in F:HJEMMESIDERGRAPHICALDESIGNGRAPHICALDESIGN.WEP.DKmailer.php on line 23

    Do you know what’s wrong?

    #67222
    AshtonSanders
    Participant

    Take out all spaces before the <?

    #67253
    Devilelites
    Member

    Thanks again – it works perfectly now :)

    #67259
    AshtonSanders
    Participant

    Excellent! [img]http://www.websitesinaflash.com/images/thumbsup.gif[/img]

    #67965
    Devilelites
    Member

    Hey again. I’m using the same script for a new website – for a friend. Do you know how to add "categories", så you can choose between somthing different things. Here’s an example:

    Booking (send mail to [email protected])
    Webmaster (send mail to [email protected])
    Questions (send mail to [email protected])

    Or something like that…

    #68078
    AshtonSanders
    Participant

    It’s not a simple answer, but I can start you in the right direction:

    You create a <select name="category"> element with the three different categories as different <options>.
    Make the value for each option ="theemail@address" for that option.

    Then change the mail function:

    Code:
    mail(“[email protected]”, ‘(GD) ‘.$subject, $_SERVER[‘REMOTE_ADDR’].”nn”.$message, “From: $from”);

    To:

    Code:
    mail(“$_POST[‘category’]”, ‘(GD) ‘.$subject, $_SERVER[‘REMOTE_ADDR’].”nn”.$message, “From: $from”);

    I would also recommending programming a validation for that field too, to make sure it is correct.

    #68105
    Devilelites
    Member

    Sounds nice – i’ll try. But what do you mean with a validation for that field?

    Edit:

    The HTML works, but when i want to send the message i get this error:

    Parse error: parse error, expecting `T_STRING’ or `T_VARIABLE’ or `T_NUM_STRING’ in F:HJEMMESIDERGRAPHICALDESIGNTEST.WEP.DKmailer.php on line 21

    My css line 21 is:

    Code:
    mail(“$_POST[‘category’]”, ‘(GD)’.$subject, $_SERVER[‘REMOTE_ADDR’].”nn”.$message, “From: $from”);
    #68109
    AshtonSanders
    Participant

    Let me see your HTML <select….>

    #68113
    Devilelites
    Member

    Here – i just tried, i’ve no experience in forms/PHP:

    Code:
    Kategori:

    #68114
    AshtonSanders
    Participant

    Replace:
    </select name>
    with:
    </select>

    Try that.

    oh, and take the quotes off of the $_Post:

    mail("$_POST",
    Should be:
    mail($_POST,

    #68115
    Devilelites
    Member

    Hmm… I can’t count how many times you’ve helped me with success – THANKS again! :)

    The error aint appearing anymore – now i just have to be sure that i get the message :)

Viewing 15 posts - 1 through 15 (of 20 total)
  • The forum ‘Back End’ is closed to new topics and replies.