0

how can i add repead function in this code for email repead ?

I have check function for email is alredy exist in database, but i want to againemail function for email re-enter. How can i do this in my code. Can anyone help me ?

<?php 
    include("includes/connect.php"); 

    if(isset($_POST['submit'])) { 
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];
        $... = $_POST['...'];

        if($...=='') {
           echo"<script>alert('please enter the ...')</script>";
           exit();
        }
        if($...=='') {
           echo"<script>alert('please enter the ...')</script>";
           exit();
        }
        if($...=='') {
           echo"<script>alert('please enter the ...')</script>";
           exit();
        }
        if($...=='') {
           echo"<script>alert('please enter the ...')</script>";
           exit();
        }

        $check_... = "SELECT * FROM ... where ...='$...'";
        $run = mysql_query($check_...);
        if(mysql_num_rows($run)>0) {
            echo "<script>alert('... $... is alredy exist in database , please try other ...')</script>";
            exit();
        }

        $query ="INSERT INTO ... (...,...,..., ...,...,...,...,...,...) VALUES ('$...','$...','$...', '$...','$...','$...','$...','$...,'$...')";

        if(mysql_query($query)) {
            echo "<script>alert('Registiration was succesfully!')</script>";
        }
    }
?> 
D. Schreier
  • 1,462
  • 1
  • 17
  • 29
EcoWebtr
  • 79
  • 1
  • 9

2 Answers2

1

I hope this is not production code because code has potentional SQL-injection (please check this What is SQL injection?). But anyway regarding your question. You need add simple checking for achieving what you want:

    ...

    if($business_name == ''){
       echo"<script>alert('please enter the usernme')</script>";
       exit();
       }
    if($email == ''){
       echo"<script>alert('please enter the email')</script>";
       exit();
       }

    //check for matching
    if($email != $emailagain){
       echo"<script>alert('entered email addresses don't match')</script>";
       exit();
       }
    $check_email = "SELECT * FROM ... where ...='$...'";
    ...
Community
  • 1
  • 1
Alexander Myshov
  • 2,455
  • 2
  • 17
  • 28
1

This is my problem solution. solution is check in the code // this is solution

if($business_name == ''){
    echo"<script>alert('please enter the usernme')</script>";
    exit();
}
if($email == ''){
    echo"<script>alert('please enter the email')</script>";
    exit();
}

//this is solution
if($_POST['email'] !== $_POST['emailagain']){
    echo"<div class='error_re-email'>entered email adresses not match</div>";
    exit();
}
$check_email = "SELECT * FROM ... where ...='$...'";
...
Alexander Myshov
  • 2,455
  • 2
  • 17
  • 28
EcoWebtr
  • 79
  • 1
  • 9