- This topic is empty.
-
AuthorPosts
-
November 28, 2009 at 9:44 am #26971
Devilelites
MemberHey,
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.November 28, 2009 at 1:36 pm #67158AshtonSanders
ParticipantWhat script did you use to create this contact form?
Did you just get some HTML code from somewhere?November 28, 2009 at 2:44 pm #67169Devilelites
MemberI searched for a script. It used PHP. Here’s the code if it helps:
Mailer.php
Code:HTML
Code:November 28, 2009 at 3:09 pm #67173AshtonSanders
ParticipantHere’;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?
November 29, 2009 at 8:07 am #67200Devilelites
MemberThank 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?
November 29, 2009 at 1:20 pm #67222AshtonSanders
ParticipantTake out all spaces before the <?
November 30, 2009 at 8:01 am #67253Devilelites
MemberThanks again – it works perfectly now :)
November 30, 2009 at 11:11 am #67259AshtonSanders
ParticipantExcellent! [img]http://www.websitesinaflash.com/images/thumbsup.gif[/img]
December 10, 2009 at 12:59 pm #67965Devilelites
MemberHey 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…
December 13, 2009 at 10:44 pm #68078AshtonSanders
ParticipantIt’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.
December 14, 2009 at 7:49 am #68105Devilelites
MemberSounds 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”);December 14, 2009 at 11:59 am #68109AshtonSanders
ParticipantLet me see your HTML <select….>
December 14, 2009 at 12:28 pm #68113Devilelites
MemberHere – i just tried, i’ve no experience in forms/PHP:
Code:Kategori:
December 14, 2009 at 12:29 pm #68114AshtonSanders
ParticipantReplace:
</select name>
with:
</select>Try that.
oh, and take the quotes off of the $_Post:
mail("$_POST",
Should be:
mail($_POST,December 14, 2009 at 12:35 pm #68115Devilelites
MemberHmm… 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 :)
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.