NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php
include_once 'db_connect.php';
include_once 'psl-config.php';
include_once 'db_connect.php';
include_once 'functions.php';

$error_msg = "";

//echo "string";
if (isset($_POST['username'], $_POST['name'])) {

// Sanitize and validate the data passed in
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);


$password = filter_input(INPUT_POST, 'p', FILTER_SANITIZE_STRING);
$shweta= filter_input(INPUT_POST, 'q', FILTER_SANITIZE_STRING);
if (strlen($password) != 128) {
// The hashed pwd should be 128 characters long.
// If it's not, something really odd has happened
$error_msg .= '<p class="error">Invalid password configuration.</p>';
}

// Username validity and password validity have been checked client side.
// This should should be adequate as nobody gains any advantage from
// breaking these rules.
//


// check existing username
$prep_stmt = "SELECT id FROM login_data WHERE username = ? LIMIT 1";
$stmt = $mysqli->prepare($prep_stmt);

if ($stmt) {
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->store_result();

if ($stmt->num_rows == 1) {
// A user with this username already exists
$error_msg .= '<p class="error">A user with this username already exists</p>';
$stmt->close();
}
$stmt->close();
} else {
$error_msg .= '<p class="error">Database error line 55</p>';
$stmt->close();
}

// TODO:
// We'll also have to account for the situation where the user doesn't have
// rights to do registration, by checking what type of user is attempting to
// perform the operation.

if (empty($error_msg)) {
// Create a random salt
//$random_salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE)); // Did not work
$random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));

// Create salted password
$password = hash('sha512', $password . $random_salt);

// Insert the new user into the database
if ($insert_stmt = $mysqli->prepare("INSERT INTO login_data (username, password, salt) VALUES (?,?,?,?)")) {
$insert_stmt->bind_param('ssss', $username, $email, $password, $random_salt);
//----------Mongo_db profile making--------------------------------//
$m = new MongoClient();
echo "Connection to database successfully";
// select a database
$db = $m->creation;
//echo "Database mydb selected";
$collection = $db->profile;
//echo "Collection selected succsessfully";
$nerd="nerd_".$username;
$email_id=$username.'@iiti.ac.in';
$document = array(
"username" => $username,
"name" => $name,
"nerd_name" => $nerd,
"department" => $branch_1,
"persue" => $persue_1,
"profile_pic" => "profile_pics/default_profile_pic.png",
"email_id" => $email_id,
"appreciations" => 0,
"contact_no" => 0,
"notifications" => [],
"geekness" => [],
"tech_club" =>[]
);

$collection->insert($document);
echo "Document inserted successfully<br>";
// Execute the prepared query.
if (! $insert_stmt->execute()) {
header('Location: ../error.php?err=Registration failure: INSERT');
}
}
echo "$username<br>$name<br>$shweta";
}
}

?>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.