Jump to content

contact form


wiredphp

Recommended Posts

Hi, I need tips and sugestions for form that I crated, just basic stuff.

Also there is couple things that I need to do:

1) when submitted, form should to print message that form is sent, or if something is not ok, to display error mesage, everything on same page example, contact.php

2) now, when form is sent I recive it on email, but feedback field, textarea give me html tags for new line and something like that

here is the code, please help:

 

<?php

if(empty($_POST["name"]))

{

die("Please provide valid name");

}

?>

 

<?php

if(is_numeric($_POST["name"]))

{

die("Please provide valid name");

}

?>

 

<?php

$email = $_POST["email"];

if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))

 

{

die("E-mail address not valid");

};

?>

<?php

if(empty($_POST["subject"]))

{

die("Plese enter a subject.");

}

?>

<?php

 

 

if(!isset($_POST['submit']))

{

$ToEmail = 'xxx@yahoo.com';

$EmailSubject = 'Pitanje sa xxx.com';

$mailheader = "From :". $_POST["email"]. "\r\n";

$mailheader .= "Reply to :". $_POST["email"]. "\r\n";

$mailheader .= "Ova poruka sadrzi pitanje postavljeno na www.xxxx.com \r\n";

$MESSAGE_BODY = "Ime : " .$_POST["name"]." \r\n";

$MESSAGE_BODY .= "Email : " .nl2br($_POST["email"])." \r\n";

$MESSAGE_BODY .= "Naslov : " .$_POST["subject"]." \r\n";

$MESSAGE_BODY .= "Poruka : " .nl2br($_POST["feedback"])." \r\n";

mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");

echo "Vasa poruka je uspjesno poslana! Kliknite <a href=\"index.html\">ovde</a> za pocetnu stranu ";

};

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.