Jump to content

Prabin

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Prabin

  1. { $getp=$_POST["password"]; $newhas=password_hash($getp,PASSWORD_BCRYPT); I am trying to use this code for password hashing for every time that password is hashed it returns a different value. How do I save the hashed value in database ?
  2. <?php //$passwordVerify = password_verify($userInput, $passwordInput); $con = mysqli_connect("127.0.0.1","root",""); if (!$con) { die('Could not connect: ' . mysqli_error()); } /*if($con){ die('Database connected successfuly.'); }*/ $sql="CREATE DATABASE IF NOT EXISTS 'itech3108_30124248_a1'"; $runquery = mysqli_query($con,$sql); if(!mysqli_select_db($con, "itech3108_30124248_a1")) { die('Database not connected: ' . mysqli_error()); } session_start(); if(isset($_POST['register'])) { //for image uploading...................... $files = $_FILES['file']; $filename = $files['name']; $filrerror = $files['error']; $filetemp = $files['tmp_name']; $fileext = explode('.', $filename); $filecheck = strtolower(end($fileext)); $fileextstored = array('png' , 'jpg' , 'jpeg'); if(in_array($filecheck, $fileextstored)){ $destinationfile = 'img/'.$filename; move_uploaded_file($filetemp, $destinationfile); } $name = $_POST['username']; $email = $_POST['email']; $confirm = $_POST['confirm']; $profile=$_POST['profile']; /*$file_ext= null; if(isset($_FILES['image'])){ $errors= array(); $file_name = $_FILES['image']['name']; $file_size =$_FILES['image']['size']; $file_tmp =$_FILES['image']['tmp_name']; $file_type=$_FILES['image']['type']; $file_ext=strtolower(end(explode('.',$_FILES['image']['name']))); $extensions= array('jpeg','jpg','png'); if(in_array($file_ext,$extensions)=== false){ $errors[]='extension not allowed, please choose a JPEG or PNG file.'; } if($file_size > 2097152){ $errors[]='File size must be excately 2 MB'; } if(empty($errors)==true){ move_uploaded_file($file_tmp,'img/'.$file_name); //echo 'Success'; }else{ print_r($errors); } } //$passwordhash = null; /* if (CRYPT_BLOWFISH == 1) { $passwordhash = password_hash($password ,PASSWORD_BCRYPT); } else { echo '<script>alert('Blowfish DES not supported.'); window.location='reg.php';</script>'; }...............................................................*/ // die('photo url='. $destinationfile.'name='.$name.'email='.$email.'password='.$password.'profile='.$profile); $sql = "INSERT INTO user ('name','email','password','profile') SET ('$name','$email','$confirm','$profile,'$destinationfile')" ; // $query="INSERT INTO 'user' ('id','name','email','password','profile','photo') VALUES( ?,?,?,?,?,?) "; // $stmt = mysqli_prepare($con, $query) or die(mysqli_error($con)); // $stmt->bind_param($stmt,'Null',$name,$email,$confirm,$profile,$destinationfile); //$stmt->execute(); //$stmt = mysqli_prepare($con, "INSERT INTO 'user' ('name','email','password','profile','photo') VALUES( ?,?,?,?,?) "); // mysqli_stmt_bind_param($stmt, $name,$email,$confirm,$profile,$destinationfile); // mysqli_stmt_execute($stmt); $runquery = mysqli_query($con,$sql); //echo 'query'.$runquery; if(!$runquery) { die( mysqli_error($con)); } else { echo '<script>alert("User successfully registered."); window.location="login.php";</script>'; } } //mysqli_query.close(); if(isset($_SESSION['name'])) { header('Location:profilepage.php'); } ?> <!DOCTYPE html> <html> <head> <title>Sign Up Page</title> <link href='https://fonts.googleapis.com/css?family=Lobster|Montserrat' rel='stylesheet'> <link rel='stylesheet' type='text/css' href='stylesheet/register.css'> </head> <header> <nav> <h1>find Your Love</h1> <ul id='navli'> <li><a class='homeblack' href='home.php'>Home</a></li> </ul> </nav> </header> <style> body{ background-image: url('img/love.jpg'); background-repeat: no-repeat; background-attachment: fixed; background-size: cover;} </style> <div class='divider'></div> <div class='loginbox'> <img src='img/love2.jpg' class='avatar'> <h1>Signup </h1> <form action='reg.php' method='POST'enctype='multipart/form-data'> <p>User Name</p> <input type='text' id='username' name='username' placeholder='Enter Username' required='requiored'></p> <p>Email</p> <input type='Email' id='email' name='email' placeholder='Enter email' required='required'> <p>Password</p> <input type='password' id='password' name='password' placeholder='Enter password' required='required'> <p>Confirm Password</p> <input type='password' id='confirm' name='confirm' placeholder='re-enter password' required='required'> <p> upload Image</p> <input class="input--style-1" type="file" placeholder="file" name="file"> <p>Your Words</p> <input type='textbox' id='profile' name='profile' placeholder=' your words to describe your self' required='required'> <input type='submit' name='register' value='Sign Up'> <div class='divider'></div> <h6><a href='login.php'>Already Have Account ? </a></h6> </form> </div> </body> </html> I am having an error with this code You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''name','email','password','profile') SET ('Sasural','kill@1234.com','kill','ANDK' at line 1 I am stuck with this for last 5hrs
×
×
  • 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.