II would like to store two values (an email and a password) in a MySQL db using PHP. The input is passed to the PHP page via Ajax in jQuery (through an onclick event on a website). Now I want to protect this PHP query against SQL injection - I am talking about a standard website so I don't want to overdo it but I think some standard protection can't be bad. Below is what I had before just to ensure that the general procedure is working which it is. I then tried to increase security by using password encryption and statements but I am not sure if I did this the right way + I don't know if and how this needs to be applied to the Select part as well (where I am checking if the email already exists). I've seen plenty of pages on this topic but as a beginner that's exactly my problem here. Can someone tell with this as an example what should be changed or added here and maybe provide some short explanations ? I would like to keep using MySQLi if possible. Old PHP: $conn = new mysqli($servername, $username, $password, $dbname); $conn-&gt;set_charset(&quot;utf8&quot;); if($conn-&gt;connect_error){     die(&quot;Connection failed: &quot; . $conn-&gt;connect_error); } $email = $_POST[&quot;email&quot;]; $pw = $_POST[&quot;pw&quot;];   $sql = &quot;SELECT email FROM Users WHERE email = '&quot; . $email . &quot;'&quot;; $query = $conn-&gt;query($sql); if(mysqli_num_rows($query) &gt; 0){     echo &quot;Record already exists&quot;; }else{     $sql = &quot;INSERT INTO Users (email, pw) VALUES ('&quot; . $email . &quot;', '&quot; . $pw . &quot;')&quot;;     if($conn-&gt;query($sql)){         echo &quot;Update successful&quot;;     }else{         echo &quot;Update failed&quot;;     }; } $conn-&gt;close();  New PHP: $conn = new mysqli($servername, $username, $password, $dbname); $conn-&gt;set_charset(&quot;utf8&quot;); if($conn-&gt;connect_error){     die(&quot;Connection failed: &quot; . $conn-&gt;connect_error); } $email = $_POST[&quot;email&quot;]; $pw = password_hash($_POST[&quot;pw&quot;], PASSWORD_BCRYPT);   $sql = &quot;SELECT email FROM Users WHERE email = '&quot; . $email . &quot;'&quot;; $query = $conn-&gt;query($sql); if(mysqli_num_rows($query) &gt; 0){     echo &quot;Record already exists&quot;; }else{     $sql = $conn-&gt;prepare(&quot;INSERT INTO Users (email, pw) VALUES ('&quot; . $email . &quot;', '&quot; . $pw . &quot;')&quot;);     $sql-&gt;bind_param('s', $name);     $sql-&gt;execute();     $result = $sql-&gt;get_result();     if($result){         echo &quot;Update successful&quot;;     }else{         echo &quot;Update failed&quot;;     }; } $conn-&gt;close();
If user input is inserted without modification into an SQL query, then the application becomes vulnerable to , like in the following example:  $unsafe_variable = $_POST['user_input'];   mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");   That's because the user can input something like value'); DROP TABLE table;--, and the query becomes:  INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--')   What can be done to prevent this from happening?
Problem from iOS 10.1.1 to 10.2.1.  I have no photos at all on my iPhone yet in settings it says my photo library is taking up ~200MB of space. The number of space being taken up keeps changing constantly(in the settings app on my phone). In iTunes, the storage bar at the bottom does(when in the sync menu) not show photos.           What is taking up this storage, and how can I reduce it?  Troubleshooting:   I disabled iCloud photo library and iCloud photo stream, still showing the same thing. Tried doing what @User9125 said, didn't work. I had set the date all the way back when I first got my phone, nothing showed up. Rebooting I had hundreds of photos in Whatsapp, I deleted them but I didn't get the storage back. It didn't even make a dent in the amount of storage being used by Photos so I don't think a third-party app could be taking up this storage. I don't think a system app is taking this space either, because I cleared the pictures in mail and messages. I tried using (through sideloading) in Secure Mode and Fast Mode, but it did not clear up the photos. How to extract Time from Date/Time field within formula How to disable javascript modal popup ads For many years I have blocked popup ads with AdBlock Plus.  But it seems more and more these past couple months there is a "new" kind of popup overtaking the web.  They are javascript based "modal" popups which ABP is powerless over.  See attached for an example.  Is there a way to kill these ads without breaking the functionality of anything I need? Find $x$ such that $(x^2 + 4x + 3)^x + (2x + 4)^x = (x^2 + 4x + 5)^x$ What is the highest power of n in $(n^r-1)!$ where $n$, $r$ are positive integers? The answer supplied is $\frac{n^r-nr+r-1}{n-1}$   The highest power of $n$ in $n^r!  = r +$ the highest power of $n$ in $(n^r-1)!$ as $n^r$ contributes $r$ powers.    So,  the highest power of $n$ in $n^r!$ needs to be $\frac{n^r-nr+r-1}{n-1} + r =\sum_{1≤t&lt;r}n^t $.    This is clearly true if $n$ were prime according to .  Again,  if $r=1$, $\frac{n^r-nr+r-1}{n-1}$ becomes $0$.    But according to , the  highest power of composite $n$ in $(n-1)! ≥ 1 $.  So, the answer does not seem to hold for $r=1$ if $n$ is composite. If $n=\prod p_i^{a_i}$, where $p_i$ are distinct primes,  $n^r=\prod p_i^{ra_i}$  So, the highest power $(q_i)$ of $p_i$ in  $n^r!$ is  $$\sum_{1≤t&lt;∞}\left\lfloor\frac{n^r}{p_i^t} \right\rfloor =\sum_{1≤t≤ra_i}\frac{n^r}{p_i^t} +\sum_{ra_i+1≤t&lt;∞}\left\lfloor\frac{n^r}{p_i^t} \right\rfloor$$  as $p^t|n^r$ for $t≤ra_i$.  So, the highest power of $p_i^{a_i}$ in  $n^r!$ is $\left\lfloor \frac{q_i}{a_i} \right\rfloor=P_i$(say).   So, the highest power of n=$\prod p_i^{a_i}$ in  $n^r!$ is $min(P_i)$  I could not proceed anymore. What should I do after a suspected compromisation of my system? Python analog of PHP's natsort function (sort a list using a "natural order" algorithm) Prove that ${\sqrt {n} }^{\sqrt {n+1}} > {\sqrt {n+1}}^{\sqrt {n}}$. In ArcMap, when you export data to PDF it preserves the layering within the PDF so that you can turn on/off individual map layers (within the PDF itself).  When I export from QGIS to PDF, I don't appear to have the option for this.  Does QGIS support preserving layers when exporting to PDF?  Is there a special setting needed to enable this capability?  Or has anyone wrote a plugin for this feature? Finding net magnetic and electric force on charged particle This is from my textbook, it is not an assigned problem, but I want to understand.   It says:      Consider the situation in the figure, in which there is a uniform electric field in the x direction and a uniform magnetic field in the y direction. For each example of a proton at rest or moving in the x, y, or z direction, what is the direction of the net electric and magnetic force on the proton at this instant?   I believe I need to use the equation   $$ F_{net}=(q\overrightarrow{E})+q(\overrightarrow{v} \times \overrightarrow{B}) $$  But I'm not sure exactly how. We've just started to learn about this, and I want to get a head start. Could anyone put me on the right track? Fast(est) and intuitive ways to look at matrix multiplication? Why the galaxies form 2D planes (or spiral-like) instead of 3D balls (or spherical-like)? Question: As we know, (1) the macroscopic spatial dimension of our universe is 3 dimension, and (2) gravity attracts massive objects together and the gravitational force is isotropic without directional preferences. Why do we have the spiral 2D plane-like Galaxy(galaxies), instead of spherical or elliptic-like galaxies?   Input: Gravity is (at least, seems to be) isotropic from its force law (Newtonian gravity). It should show no directional preferences from the form of force vector $\vec{F}=\frac{GM(r_1)m(r_2)}{(\vec{r_1}-\vec{r_2})^2} \hat{r_{12}}$. The Einstein gravity also does not show directional dependence at least microscopically.  If the gravity attracts massive objects together isotropically, and the macroscopic space dimension is 3-dimensional, it seems to be natural to have a spherical shape of massive objects gather together. Such as the globular clusters, or GC, are roughly spherical groupings , as shown in the Wiki picture:     However, my impression is that, even if we have observed some more spherical or more-ball-like , it is more common to find more-planar  such as our ? (Is this statement correct? Let me know if I am wrong.)  Also, such have a look at this more-planar Spiral "galaxy" as this NGC 4414 galaxy:    Is there some physics or math theory explains why the  turns out to be planar-like (or spiral-like) instead of spherical-like?  See also a   p.s. Other than the classical stability of a 2D plane perpendicular to a classical angular momentum, is there an interpretation in terms of the quantum theory of vortices in a macroscopic manner (just my personal speculation)?  Thank you for your comments/answers! According to general relativity, inertial mass and gravitational mass are the same, and all accelerated reference frames (such as a uniformly rotating reference frame with its proper time dilation) are physically equivalent to a gravitational field of the same strength.  Refer: Einstein's thought experiment of a Physicist in an Accelerated Box.  I find that the 'How' part of this question is somewhat easy to understand Mathematically but hard to visualize physically and on the 'Why' part I am totally blank. Covering estate tax on US assets for non-resident alien I am a non-resident alien holding a brokerage account in the USA but residing outside the USA. My country does not have an estate tax treaty with the USA. So my estate is liable for a significant estate tax up to 40%. Is there any way to avoid or to cover this tax? I thought of buying term insurance for myself, but I am not sure whether US companies will sell term insurance to a non-resident. I want to buy insurance from a US company because I want the death benefit to be in USD. Can someone suggest as to what the best way to approach this issue is? Find all $n \in \mathbb{N}$ such that $\phi(n) = 4294967296=2^{32}$.  I managed to find that $16106127360$, $8589934592$, $10737418240$ and $12884901888$ are solutions for the equation, but I do not know how to find all of them. Find $\min(\operatorname{trace}(AA^T))$ for invertible $A_{n\times n}$ For invertible $A_{n\times n}$ find $\min(\operatorname{trace}(AA^T))$  (a) $0$ (b) $1$ (c) $n$ (d) $n^2$  Clearly for $A=I$, it is $n$, and I am unable to get any lower values, but how do I prove it. Present-perfect-tense vs. Simple-past-tense Tikz, Tree without overlaps How unique is the php session id How unique is the php session id? I got the impression from various things that I've read that I should not rely on two users never getting the same sessionid. Isn't it a GUID? Checking if a double (or float) is NaN in C++