user3046898
user3046898

Reputation:

Repeat email for registiration form in php

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>";
        }
    }
?> 

Upvotes: 0

Views: 430

Answers (1)

Alexander Myshov
Alexander Myshov

Reputation: 3101

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 ...='$...'";
    ...

Upvotes: 0

Related Questions