Results 1 to 2 of 2

Thread: currently setting up the NewsLetters function,but validation of @ always fail

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default currently setting up the NewsLetters function,but validation of @ always fail

    I am trying to built a complex website: http://www.poliscarhire.com/ ,
    currently setting up the NewsLetters function, but when in homepage above(and to all pages) I insert a valid email to subscribute a message from email validation says always: "InValid email address. Please retry ! " , well ? code to subscribute.php below:

    Code:
    <html>
    .....<strong>
              <?php
    $email = $_POST['email'];
    
    include("../dbinfo.php");
    $linkid = @mysql_connect($hostname,$username,$password) or die( "Unable to connect to Database Server. Please try again later.");  
    @mysql_select_db($database,$linkid) or die( "Unable to select database.  Please try again later,");   // @
    
    if ($_POST['unsubscribute']) {
      $query = "SELECT * FROM $NewslettersTable";   
      $result = @mysql_query($query,$linkid) or die( "Unable to execute query. Please try again later.");  
      $count = @mysql_num_rows($result); 
      for ($j=0;$j<$count;$j++) {
         $row = mysql_fetch_row($result);
         if ($email != $row['email']) {
              echo "This email address does NOT exist, in the database !";
              break;
         }
         $query = "DELETE FROM $NewslettersTable WHERE email='$email'";   
         $result = @mysql_query($query,$linkid) or die( "Unable to execute query. Please try again later.");  
         echo "You have successfully UnSubscribute from our 'Newsletter (Latest Offers)' as: \n". $email; 
      } 
    }
    else {
     if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
      $query = "SELECT * FROM $NewslettersTable";   
      $result = @mysql_query($query,$linkid) or die( "Unable to execute query. Please try again later.");  
      $count = @mysql_num_rows($result); 
      for ($j=0;$j<$count;$j++) {
         $row = mysql_fetch_row($result);
         if ($email == $row['email']) {
              echo "This email address already exist, in the database !";
              break;
         }
    	 // mysql_free_result($result);
         $query = "INSERT INTO $NewslettersTable VALUES(NULL,'$email')";   
         $result = @mysql_query($query,$linkid) or die( "Unable to execute query. Please try again later.");  
         echo "You have successfully Subscribute to our 'Newsletter (Latest Offers)' as: \n". $email; 
      } // end for
     } else {   
        echo "InValid email address. Please retry !";
     }  // end if
    } // end if main
    // mysql_free_result($result);
    mysql_close($linkid);
    ?>
              </strong> 
    ....
    </html>

  2. #2
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    $_POST['unsubscribute']
    'unsubscribute'=button name/id

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •