Jump to content

Simple PHP form req


woprman

Recommended Posts

Hello!

 

My form works great, the only problem is it still works if the textbox is blank.

 

I just need it to either not submit OR make the box say error: enter email.

 

the code:

 

<?php

 

$EmailFrom = "WOP";

$EmailTo = "[email protected]";

$Subject = "Contact Inquiery";

$subscribe = Trim(stripslashes($_POST['subscribe']));

 

// validation

 

 

$validationOK=true;

if (!$validationOK) {

  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

  exit;

}

 

// prepare email body text

$Body = "";

$Body .= "subscribe: ";

$Body .= $subscribe;

$Body .= "\n";

 

 

// send email

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

 

// redirect to success page

if ($success){

  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";

}

else{

  print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">";

}

?>

 

 

Please help!

Link to comment
https://forums.phpfreaks.com/topic/194462-simple-php-form-req/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.