页脚消失在PHP中执行die函数后

时间:2015-03-20 15:29:03

标签: php

我在这里需要一些帮助。 Anyhelp非常感谢。由于die命令,我的第一个带有die命令的代码和页脚将不会显示。所以我已经从die命令更改为if else功能。这是我编辑的代码。问题是无法将新数据插入数据库。

         <?php 
    // Connects to your Database 
    mysql_connect("localhost", "root", "") or die(mysql_error()); 
    mysql_select_db("destiku_db") or die(mysql_error()); 


    //This code runs if the form has been submitted
    if (isset($_POST['submit'])) 
    { 

        //This makes sure they did not leave any fields blank
        if (!$_POST['email'] | !$_POST['password'] | !$_POST['password2'] ) 
        { echo "You did not complete all of the required fields"; }

        // this makes sure both passwords entered match
        elseif ($_POST['password'] != $_POST['password2']) 
        { 
            echo "Your passwords did not match."; 

            // here we encrypt the password and add slashes if needed
            $_POST['password'] = md5($_POST['password2']);

            if (!get_magic_quotes_gpc()) 
            {
                $_POST['password'] = addslashes($_POST['password']);
                $_POST['email'] = addslashes($_POST['email']);
            }
        }

        // checks if the email is in use
        elseif (!get_magic_quotes_gpc()) 
        { 
            $_POST['email'] = addslashes($_POST['email']);

            $usercheck = $_POST['email'];
            $check = mysql_query("SELECT u_email FROM user_login WHERE u_email = '$usercheck'");
            $check2 = mysql_num_rows($check);

            //if the name exists it gives an error
            if ($check2 != 0) 
            { echo"Sorry, the email ";?> <?php $_POST['email'] ?> <?php echo"is already in use."; }
        } 

        else
        {   

            // now we insert it into the database
            $insert = "INSERT INTO user_login (u_email, u_password) VALUES ('".$_POST['email']."', '".$_POST['password']."')";
            $add_member = mysql_query($insert);


          echo"
            <h1>Registered</h1>
            <p>Thank you, you have registered - you may now
            <a href=index.php?1=php&page=login>Login</a>.</p>"; 
        }

    } 

    else 
    {   
    ?>

        <form action="<?php echo"index.php?1=php&page=registration"; ?>" method="post">
        <table border="0">
        <tr><td>Email:</td><td><input type="text" name="email" maxlength="60"></td></tr>

        <tr><td>Password:</td><td><input type="password" name="password" maxlength="10"></td></tr>

        <tr><td>Confirm Password:</td><td><input type="password" name="password2" maxlength="10"></td></tr>

        <tr><th colspan=2><input type="submit" name="submit" value="Register"></th></tr> 
        </table>
        </form>

    <?php
    }
    ?> 

先谢谢。

0 个答案:

没有答案