NameSilo

PHP Contact Form Help

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
Change
PHP:
if ($myemail != "")
into
PHP:
if ($myemail != "" && $notes!="")
and it should do the trick.
 
0
•••
Ok thanks!

Matt
 
Last edited:
0
•••
You shouldn't have to check $myemail, as you are assigning it.
 
0
•••
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
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back