I need help with a simple PHP code

paymymortgage4me

Junior Member
Joined
Apr 5, 2008
Messages
163
Reaction score
310
I'm trying to get build my mailing list. Currently on my website, I have an opt-in form. When people enter their name and email addy, I get an email with that information and they are then sent to another page that says thanks for signing up...

How can I make it so if one or both fields are left blank, they can't hit the submit button? Or they just don't go to the thanks page.

Here's the code I'm using:

Code:
<?php
  $name = $_REQUEST['name'] ;
  $email = $_REQUEST['email'] ;

  mail( "[email protected]", "New Email Submit",
    $name, $email );
  header( "Location: http://www.mywebsite.com/main.html" );
?>

I know almost nothing about PHP. I hope this is the right place.

Thanks in advance.
 
is this being done via Wordpress or just a normal php site..
what is the opt-in form made from..
is it thru aweber or something like that or is it some stand alone code.
I would assume it is linked to some dbase as well eh..

Need more details
 
Just a little improvement as you required:
Code:
<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;

if($name=="" || $email=="") {
  echo "Both fields are required!";
} else {
  mail( "myemailaddress@gmail .com", "New Email Submit", $name, $email );
  header( "Location: ht tp://www .my website .com /main.html" );
}
?>
For better improvement, please PM me!
 
good on you buileminh

eventually someone comes to the party and offers help....
 
Thanks for the help buileminh. This seems to be do exactly what I was trying to do. You guys are great!
 
Thanks for the question and reply...I was gonna post a similar question. Hey paymymortgage4me, are you using a email service like aweber or having it submitted to a db?
 
hey benitomol,

With this site, I'm actually just storing the email addresses in a group in my gmail account. My list currently has 4 email addresses in it! no point in paying for aweber yet.
 
Back
Top