Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

PHP Contact Form Help

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

170designs

Established Member
Impact
7
Hello, I need some help with my contact us form. What coding do I need to add to the following in order for it to check to make sure that the user has completed the "Message" field before they hit Send? If the message box is left blank, I do not want the email to send. Please tell me exactly what code I need to add to the code below and where I need to add it. Thanks and I greatly appreciate your help.

Here's the code:
PHP:
<?php 

$myemail = "*****@170designs.com"; 

if (!isset($visitormail)) 
echo "Somebody Goofed $ip" ; 

$todayis = date("l, F j, Y, g:i a") ; 

$subject = "$subject" ; 

$message = "$todayis [EST] \n 
Name: $visitor ($visitormail)\n 
Message: $notes \n 

"; 

$from = "From: $visitormail\n"; 

if ($myemail != "") 
mail($myemail, $subject, $message, $from); 

?>

Thanks,
Matt
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Change
PHP:
if ($myemail != "")
into
PHP:
if ($myemail != "" && $notes!="")
and it should do the trick.
 
0
Close
Ok thanks!

Matt
 
Last edited:
0
Close
You shouldn't have to check $myemail, as you are assigning it.
 
0
Close
eagle12 said:
You shouldn't have to check $myemail, as you are assigning it.

Yep, exactly what I was thinking. It'll never be blank as you've assigned something to it anyway. Should just be..

PHP:
if ($notes != "")
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

A browser tab with a favicon next to the page title
Search members
You can now search for members by name, company, location and more. Open the search at the top of any page and choose Members. You will...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back