php mysqli secure update profile picture [on hold]












-3















can i help me i have created profile picture update in php mysqli i wont to know this script can i use to my website and is there some secure? this script good or bad please help me



      <?php
include("database/config.php");
if($_SERVER['REQUEST_METHOD'] == "POST"){
//$id=$_GET['editid'];
$user_id = $_SESSION['user_id'];
$profile_pic=$row["profile_pic"];
$profile_pic= $_FILES['image']['name'];
$random = substr(number_format(time() * rand(),0,'',''),0,10);
$profile_pic= $random .$_FILES['image']['name'];
$image_tmp= $_FILES['image']['tmp_name'];
if(move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic")){
//move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic");
$stmt = $con->prepare("UPDATE users SET profile_pic=? WHERE user_id=?");
$stmt->bind_param("ss", $profile_pic, $user_id);
}else{
$stmt = $con->prepare("UPDATE users SET user_id=?");
$stmt->bind_param("s", $user_id);
}
if($stmt->execute()){
header("location:profile.php");
}else{
echo "<p>Select your profile picture and update</p> <br/>";
}
}
?>









share|improve this question







New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Gerrit0, Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13, 200_success yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 3





    @Welcome to Code Review! Did you write this yourself? To the best of your knowledge, does it work to the best of your expectations?

    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago











  • Surely this is broken code, right? ...if move_uploaded_file() is false then UPDATE all rows in the table with $user_id? Sorry, I have to flag this one as Very Low Quality. Please put more care into composing your question and snippet so that it is easier to read and more attractive to answer.

    – mickmackusa
    2 days ago


















-3















can i help me i have created profile picture update in php mysqli i wont to know this script can i use to my website and is there some secure? this script good or bad please help me



      <?php
include("database/config.php");
if($_SERVER['REQUEST_METHOD'] == "POST"){
//$id=$_GET['editid'];
$user_id = $_SESSION['user_id'];
$profile_pic=$row["profile_pic"];
$profile_pic= $_FILES['image']['name'];
$random = substr(number_format(time() * rand(),0,'',''),0,10);
$profile_pic= $random .$_FILES['image']['name'];
$image_tmp= $_FILES['image']['tmp_name'];
if(move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic")){
//move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic");
$stmt = $con->prepare("UPDATE users SET profile_pic=? WHERE user_id=?");
$stmt->bind_param("ss", $profile_pic, $user_id);
}else{
$stmt = $con->prepare("UPDATE users SET user_id=?");
$stmt->bind_param("s", $user_id);
}
if($stmt->execute()){
header("location:profile.php");
}else{
echo "<p>Select your profile picture and update</p> <br/>";
}
}
?>









share|improve this question







New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Gerrit0, Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13, 200_success yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 3





    @Welcome to Code Review! Did you write this yourself? To the best of your knowledge, does it work to the best of your expectations?

    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago











  • Surely this is broken code, right? ...if move_uploaded_file() is false then UPDATE all rows in the table with $user_id? Sorry, I have to flag this one as Very Low Quality. Please put more care into composing your question and snippet so that it is easier to read and more attractive to answer.

    – mickmackusa
    2 days ago
















-3












-3








-3








can i help me i have created profile picture update in php mysqli i wont to know this script can i use to my website and is there some secure? this script good or bad please help me



      <?php
include("database/config.php");
if($_SERVER['REQUEST_METHOD'] == "POST"){
//$id=$_GET['editid'];
$user_id = $_SESSION['user_id'];
$profile_pic=$row["profile_pic"];
$profile_pic= $_FILES['image']['name'];
$random = substr(number_format(time() * rand(),0,'',''),0,10);
$profile_pic= $random .$_FILES['image']['name'];
$image_tmp= $_FILES['image']['tmp_name'];
if(move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic")){
//move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic");
$stmt = $con->prepare("UPDATE users SET profile_pic=? WHERE user_id=?");
$stmt->bind_param("ss", $profile_pic, $user_id);
}else{
$stmt = $con->prepare("UPDATE users SET user_id=?");
$stmt->bind_param("s", $user_id);
}
if($stmt->execute()){
header("location:profile.php");
}else{
echo "<p>Select your profile picture and update</p> <br/>";
}
}
?>









share|improve this question







New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












can i help me i have created profile picture update in php mysqli i wont to know this script can i use to my website and is there some secure? this script good or bad please help me



      <?php
include("database/config.php");
if($_SERVER['REQUEST_METHOD'] == "POST"){
//$id=$_GET['editid'];
$user_id = $_SESSION['user_id'];
$profile_pic=$row["profile_pic"];
$profile_pic= $_FILES['image']['name'];
$random = substr(number_format(time() * rand(),0,'',''),0,10);
$profile_pic= $random .$_FILES['image']['name'];
$image_tmp= $_FILES['image']['tmp_name'];
if(move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic")){
//move_uploaded_file($image_tmp,"user/profile_picture/$profile_pic");
$stmt = $con->prepare("UPDATE users SET profile_pic=? WHERE user_id=?");
$stmt->bind_param("ss", $profile_pic, $user_id);
}else{
$stmt = $con->prepare("UPDATE users SET user_id=?");
$stmt->bind_param("s", $user_id);
}
if($stmt->execute()){
header("location:profile.php");
}else{
echo "<p>Select your profile picture and update</p> <br/>";
}
}
?>






php






share|improve this question







New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









ranjeewaranjeewa

1




1




New contributor




ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ranjeewa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Gerrit0, Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13, 200_success yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Gerrit0, Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13, 200_success yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Stephen Rauch, Sᴀᴍ Onᴇᴌᴀ, mdfst13

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 3





    @Welcome to Code Review! Did you write this yourself? To the best of your knowledge, does it work to the best of your expectations?

    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago











  • Surely this is broken code, right? ...if move_uploaded_file() is false then UPDATE all rows in the table with $user_id? Sorry, I have to flag this one as Very Low Quality. Please put more care into composing your question and snippet so that it is easier to read and more attractive to answer.

    – mickmackusa
    2 days ago
















  • 3





    @Welcome to Code Review! Did you write this yourself? To the best of your knowledge, does it work to the best of your expectations?

    – Sᴀᴍ Onᴇᴌᴀ
    2 days ago











  • Surely this is broken code, right? ...if move_uploaded_file() is false then UPDATE all rows in the table with $user_id? Sorry, I have to flag this one as Very Low Quality. Please put more care into composing your question and snippet so that it is easier to read and more attractive to answer.

    – mickmackusa
    2 days ago










3




3





@Welcome to Code Review! Did you write this yourself? To the best of your knowledge, does it work to the best of your expectations?

– Sᴀᴍ Onᴇᴌᴀ
2 days ago





@Welcome to Code Review! Did you write this yourself? To the best of your knowledge, does it work to the best of your expectations?

– Sᴀᴍ Onᴇᴌᴀ
2 days ago













Surely this is broken code, right? ...if move_uploaded_file() is false then UPDATE all rows in the table with $user_id? Sorry, I have to flag this one as Very Low Quality. Please put more care into composing your question and snippet so that it is easier to read and more attractive to answer.

– mickmackusa
2 days ago







Surely this is broken code, right? ...if move_uploaded_file() is false then UPDATE all rows in the table with $user_id? Sorry, I have to flag this one as Very Low Quality. Please put more care into composing your question and snippet so that it is easier to read and more attractive to answer.

– mickmackusa
2 days ago












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Сан-Квентин

8-я гвардейская общевойсковая армия

Алькесар