Jump to content

Recommended Posts

Hello, i want to make my form detects more than one duplicate entry, my coding here now only detects duplicate username only, how can i make it detects other things not just username only? Can someone fix my code here?

 

<?php
include "db_connect.php";

if( isset( $_SESSION['username'] ) )
{
$username = $_SESSION['username'];
//echo $username;

$result = mysql_query("SELECT * FROM users WHERE username = '$username'",$link) or die ("Database Error");
while ($row = mysql_fetch_assoc($result))
{
$userLevel = $row['userlevel'];
//echo $userLevel;
}

}
?>

<?php
include "db_connect.php";

error_reporting(E_ALL ^ E_NOTICE);

$name = $_POST['name'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = md5 ($_POST['password']);
$matrix = $_POST['matrix'];
$date= date("Y-m-d");
$phone = $_POST['phone'];


//$sql="SELECT matrix FROM registering WHERE matrix='".$_POST['matrix']."'";
//$query= mysql_query($sql);
//$row=mysql_num_rows($query);
if (empty($_POST['matrix'])){
echo 'Please insert matrix number';
}
else{
//if($row == 0){
// echo "No matrix in database...Please contact admin to register<br />";
//}
//else{
$sql2="INSERT INTO users(matrix, name , username , email , password , date , phone)
VALUES ('".$matrix."','".$name."','".$username."','".$email."','".$password."','".$date."', '".$phone."')";
mysql_query($sql2) or die ('<center><h1><font color=red>Error Updating Database! <br>Username already in database!. <br>Please choose another username<br><br><INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;">');

echo "Registration Successful!<br />";
echo "Please go to [<a href='index.php'>Main Page</a>] to login..";
}
//}

?>
Edited by ignace
Please, use code tags not quote tags.
Link to comment
https://forums.phpfreaks.com/topic/275549-php-detects-duplicate-entry-in-database/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.