1 Reply Latest reply on Oct 6, 2011 12:21 PM by Ahir Nitesh

    PHP Database

    ebgames56pp Level 1

      I have a issue with my subscribe.php

       

       

      i want when a email is typed in the text box to put the email in the database

       

       

      though it isnt going there, here is the code

       

       

      <?php

       

       

      if(isset($_POST['add'])){

      require_once('mysqlCreds.php');

      $email = $_POST['email'];

       

       

      if($email == ''){

      header('Refresh: 5; url=http://szeryk.com/homepage');

      echo "<div style='color: #FFFFFF;'>Please enter an email address to subscribe.</div>

      ";

      echo "<div style='color: #FFFFFF;'>If you aren't re-dreicted in a few seconds please click <a href='http://szeryk.com/homepage'>here</a></div>";

      }

       

       

      $result = mysql_query("SELECT * FROM emailList WHERE email='$email' LIMIT 1")or die(mysql_error());

      while($row = mysql_fetch_array($result)){

      if($row['email'] == $email){

      header('Refresh: 5; url=http://szeryk.com/homepage');

      echo "<div style='color: #FFFFFF;'>We are sorry, but this Email address is already subscribed.</div>

      ";

      echo "<div style='color: #FFFFFF;'>If you aren't re-dreicted in a few seconds please click <a href='http://szeryk.com/homepage/'>here</a></div>";

      mysql_query("INSERT INTO emailList (id, email) VALUES('', '$email') ")or die(mysql_error());

      header('Refresh: 5; url=http://szeryk.com/homepage');

      echo "<div style='color: #FFFFFF;'>Thank you for subscribing to the newsleter!</div>";

      echo "

      ";

      echo "<div style='color: #FFFFFF;'>If you aren't re-dreicted in a few seconds please click <a href='http://szeryk.com/homepage'>here</a></div>";          }

      }

      }

      ?>

       

       

      though if you can help me i will pay you BIG TIME

       

       

      if you can use teamviewer add me on msn

       

       

      therealmattbrown@hotmail.com

       

       

      thanks

        • 1. Re: PHP Database
          Ahir Nitesh Level 1

          Check below updated code:

           

           

          <?php

           

           

          if(isset($_POST['add']))

          {

                    require_once('mysqlCreds.php');

                    $email = trim($_POST['email']);

           

           

                    if($email == '')

                    {

                              header('Refresh: 5; url=http://szeryk.com/homepage');

                              echo "<div style='color: #FFFFFF;'>Please enter an email address to subscribe.</div>

                              ";

                              echo "<div style='color: #FFFFFF;'>If you aren't re-dreicted in a few seconds please click <a href='http://szeryk.com/homepage'>here</a></div>";

                    }

           

           

                    $result = mysql_query("SELECT * FROM emailList WHERE email = '".$email."' LIMIT 1")or die(mysql_error());

           

           

                    if(mysql_num_rows($result) > 0)

                    {

           

           

                              header('Refresh: 5; url=http://szeryk.com/homepage');

                              echo "<div style='color: #FFFFFF;'>We are sorry, but this Email address is already subscribed.</div>

                              ";

                              echo "<div style='color: #FFFFFF;'>If you aren't re-dreicted in a few seconds please click <a href='http://szeryk.com/homepage/'>here</a></div>";

                    }

                    else

                    {

                              mysql_query("INSERT INTO emailList (id, email) VALUES('', '".$email."') ")or die(mysql_error());

                              header('Refresh: 5; url=http://szeryk.com/homepage');

                              echo "<div style='color: #FFFFFF;'>Thank you for subscribing to the newsleter!</div>";

                              echo "

                              ";

                              echo "<div style='color: #FFFFFF;'>If you aren't re-dreicted in a few seconds please click <a href='http://szeryk.com/homepage'>here</a></div>";

                    }

          }

           

           

          ?>

           

          I hope this will help you to find your answer