Jump to content

enhanced08

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

About enhanced08

  • Birthday 01/18/1987

Contact Methods

Profile Information

  • Gender
    Not Telling

enhanced08's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Alright, I will remove it. Thank you both very much, Im sure Ill be back asking more questions in the future.
  2. Ok, that does make sense and is much easier than what I was trying to do. One question I do have, it may not be directly related, however, is what exactly is/does the "0" do here: $sql=mysql_query($query, 0); I know I have that in my original code but thats because someone else told me I need it, Im just not sure what it is for.
  3. Ive been having this problem for awhile. Basically what I want to do is a mailing list. I want to have a user enter an email address and have it added to a database. i want a script that will check for an input (to make sure they dont hit submit before they type anything), check to make sure the data is an email address, and query the database to see if it is already there. I was able to get the data verification and email verification to work but I can not get it to check the database. I have tried and tried, Im no pro at PHP by any means and am learning as I go. Can someone tell me what Im doing wrong? I thought this was going to be simple. Here is my code: <? $db_user="**********"; $db_pass="**********"; $database="**********"; $host="**************"; $sent_email=$_POST['email']; $sent_email=strtolower($sent_email); $error='';//initialize $error to blank mysql_connect($host, $db_user, $db_pass); @mysql_select_db($database) or die( "Unable to select database"); if(trim($sent_email)==''){ $error="An email address is required!<br />"; } else { $query="SELECT * FROM mailing_list WHERE email=$sent_email"; $result=mysql_query($query, 0) or die(mysql_error()); if($result==$sent_email){ $error="Your email address is already in our database.<br />"; } else { if(!preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $_POST['email'])) { $error="<p>The e-mail you entered was not in the proper format!<br><br> Try again.<br> <form action=mailing_list_add.php method=post accept-charset=utf-8> <table border=0 cellspacing=2 cellpadding=0> <tr><th>Email</th><td><input type=text name=email class=text></td></tr> </td></tr> <tr><td class=submission colspan=2><input type=submit name=s value=Submit></td></tr> </table> </form>"; } } } if($error==''){ { $query="INSERT INTO mailing_list VALUES ('','$sent_email')"; mysql_query($query); mysql_close(); } //echo "<script type=\"text/javascript\"> window.location = \"thankyou2.htm\"</script>"; } else{ echo "<span style=color:red>$error</span>"; } ?>
×
×
  • 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.