Click here to Skip to main content
14,639,973 members
Home » Discussions » Database
   

Database

 
QuestionSql server deadlock issue with table bulk insert and update on same table Pin
kali siddhu29-Jun-20 21:18
Memberkali siddhu29-Jun-20 21:18 
AnswerRe: Sql server deadlock issue with table bulk insert and update on same table Pin
Richard MacCutchan29-Jun-20 21:54
mveRichard MacCutchan29-Jun-20 21:54 
GeneralRe: Sql server deadlock issue with table bulk insert and update on same table Pin
kali siddhu30-Jun-20 23:29
Memberkali siddhu30-Jun-20 23:29 
GeneralRe: Sql server deadlock issue with table bulk insert and update on same table Pin
Richard MacCutchan30-Jun-20 23:31
mveRichard MacCutchan30-Jun-20 23:31 
GeneralRe: Sql server deadlock issue with table bulk insert and update on same table Pin
David Mujica1-Jul-20 5:36
MemberDavid Mujica1-Jul-20 5:36 
GeneralRe: Sql server deadlock issue with table bulk insert and update on same table Pin
kali siddhu15-Jul-20 23:44
Memberkali siddhu15-Jul-20 23:44 
AnswerRe: Sql server deadlock issue with table bulk insert and update on same table Pin
ZurdoDev1-Jul-20 7:03
mveZurdoDev1-Jul-20 7:03 
QuestionHttp 500 error with register page Pin
and180y29-Jun-20 4:31
Memberand180y29-Jun-20 4:31 
Hi Could anyone help me with the following code? It was working fine until I inserted a username column in the DB table and edited this to suit (I thought) It gives an HTTP500 error page not working.

<?php
// Include config file
require_once "config.php";
 
// Define variables and initialize with empty values
$email = $password = $confirm_password = "";
$username_err = $username = $confirm_username_err = "";
$email_err = $password_err = $confirm_password_err = "";
 
// Processing form data when form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST"){
 
    // Validate username
    if(empty(trim($_POST["email"]))){
        $email_err = "Please enter your email.";
    } else{
        // Prepare a select statement
        $sql = "SELECT id FROM users WHERE email = ?";
        
        if($stmt = mysqli_prepare($link, $sql)){
            // Bind variables to the prepared statement as parameters
            mysqli_stmt_bind_param($stmt, "s", $param_email);
            
            // Set parameters
            $param_email = trim($_POST["email"]);
            
            // Attempt to execute the prepared statement
            if(mysqli_stmt_execute($stmt)){
                /* store result */
                mysqli_stmt_store_result($stmt);
                
                if(mysqli_stmt_num_rows($stmt) == 1){
                    $email_err = "This email is already registered.";
                } else{
                    $email = trim($_POST["email"]);
                }
            } else{
                echo "Oops! Something went wrong. Please try again later.";
            }

            // Close statement
            mysqli_stmt_close($stmt);
        }
	 }
    
    // Validate username
    if(empty(trim($_POST["username"]))){
        $username_err = "Please enter a username.";     
    } elseif(strlen(trim($_POST["username"])) < 6){
        $username_err = "username must have atleast 6 characters.";
    } else{
        $username = trim($_POST["username"]);
    }	
    }
    
    // Validate password
    if(empty(trim($_POST["password"]))){
        $password_err = "Please enter a password.";     
    } elseif(strlen(trim($_POST["password"])) < 6){
        $password_err = "Password must have atleast 6 characters.";
    } else{
        $password = trim($_POST["password"]);
    }
    
    // Validate confirm password
    if(empty(trim($_POST["confirm_password"]))){
        $confirm_password_err = "Please confirm password.";     
    } else{
        $confirm_password = trim($_POST["confirm_password"]);
        if(empty($password_err) && ($password != $confirm_password)){
            $confirm_password_err = "Password did not match.";
        }
    }
    
    // Check input errors before inserting in database
    if(empty($email_err) && empty($password_err) && empty($confirm_password_err)){
        
        // Prepare an insert statement
        $sql = "INSERT INTO users (email, username, password) VALUES (?, ?)";
         
        if($stmt = mysqli_prepare($link, $sql)){
            // Bind variables to the prepared statement as parameters
            mysqli_stmt_bind_param($stmt, "ss", $param_email,$param_username $param_password);
            
            // Set parameters
            $param_email = $email;
			$param_username = $username
            $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
            
            // Attempt to execute the prepared statement
            if(mysqli_stmt_execute($stmt)){
                // Redirect to login page
                header("location: login.php");
            } else{
                echo "Something went wrong. Please try again later.";
            }

            // Close statement
            mysqli_stmt_close($stmt);
        }
    }
    
    // Close connection
    mysqli_close($link);
}
?>
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sign Up</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
    <style type="text/css">
        body{ font: 14px sans-serif; }
        .wrapper{ width: 350px; padding: 20px; }
    </style>
</head>
<body>
    <div class="wrapper">
        <h2>Sign Up</h2>
        <p>Please fill this form to create an account.</p>
        <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
            <div class="form-group <?php echo (!empty($email_err)) ? 'has-error' : ''; ?>">
                <label>Email</label>
                <input type="text" name="email" class="form-control" value="<?php echo $email; ?>">
                <span class="help-block"><?php echo $email_err; ?></span>
            </div>
			<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
            <div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
                <label>Username</label>
                <input type="text" name="username" class="form-control" value="<?php echo $username; ?>">
                <span class="help-block"><?php echo $username_err; ?></span>
            </div> 
            <div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
                <label>Password</label>
                <input type="password" name="password" class="form-control" value="<?php echo $password; ?>">
                <span class="help-block"><?php echo $password_err; ?></span>
            </div>
            <div class="form-group <?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?>">
                <label>Confirm Password</label>
                <input type="password" name="confirm_password" class="form-control" value="<?php echo $confirm_password; ?>">
                <span class="help-block"><?php echo $confirm_password_err; ?></span>
            </div>
            <div class="form-group">
                <input type="submit" class="btn btn-primary" value="Submit">
                <input type="reset" class="btn btn-default" value="Reset">
            </div>
            <p>Already have an account? <a href="login.php">Login here</a>.</p>
        </form>
    </div>    
</body>
</html>

AnswerRe: Http 500 error with register page Pin
ZurdoDev29-Jun-20 4:33
mveZurdoDev29-Jun-20 4:33 
GeneralRe: Http 500 error with register page Pin
and180y29-Jun-20 4:45
Memberand180y29-Jun-20 4:45 
GeneralRe: Http 500 error with register page Pin
ZurdoDev29-Jun-20 4:49
mveZurdoDev29-Jun-20 4:49 
AnswerRe: Http 500 error with register page Pin
Richard Deeming29-Jun-20 5:15
mveRichard Deeming29-Jun-20 5:15 
GeneralRe: Http 500 error with register page Pin
and180y29-Jun-20 5:21
Memberand180y29-Jun-20 5:21 
GeneralRe: Http 500 error with register page Pin
and180y29-Jun-20 7:40
Memberand180y29-Jun-20 7:40 
GeneralRe: Http 500 error with register page Pin
Richard MacCutchan29-Jun-20 9:36
mveRichard MacCutchan29-Jun-20 9:36 
GeneralRe: Http 500 error with register page Pin
and180y29-Jun-20 12:37
Memberand180y29-Jun-20 12:37 
GeneralRe: Http 500 error with register page Pin
Richard MacCutchan29-Jun-20 21:44
mveRichard MacCutchan29-Jun-20 21:44 
GeneralRe: Http 500 error with register page Pin
and180y1-Jul-20 8:03
Memberand180y1-Jul-20 8:03 
GeneralRe: Http 500 error with register page Pin
Richard MacCutchan1-Jul-20 9:10
mveRichard MacCutchan1-Jul-20 9:10 
GeneralRe: Http 500 error with register page Pin
and180y1-Jul-20 9:42
Memberand180y1-Jul-20 9:42 
GeneralRe: Http 500 error with register page Pin
and180y1-Jul-20 13:11
Memberand180y1-Jul-20 13:11 
GeneralRe: Http 500 error with register page Pin
Richard MacCutchan1-Jul-20 22:37
mveRichard MacCutchan1-Jul-20 22:37 
GeneralRe: Http 500 error with register page Pin
and180y2-Jul-20 4:57
Memberand180y2-Jul-20 4:57 
QuestionReporting data Pin
Joan M19-Jun-20 10:03
professionalJoan M19-Jun-20 10:03 
AnswerRe: Reporting data Pin
Mycroft Holmes19-Jun-20 12:25
professionalMycroft Holmes19-Jun-20 12:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.