UPDATE tabela

I cant update

if (isset($_POST['submit'])) {
    $sql = "UPDATE users SET paid='1', WHERE email = '".$email."'";
	}
CREATE TABLE `users` (
  `user_id` int(5) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `username` varchar(25) NOT NULL,
  `password` varchar(255) NOT NULL,
  `Last_name` varchar(255) NOT NULL,
  `City` varchar(255) NOT NULL,
  `Phone` varchar(255) NOT NULL,
  `paid` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

There’s no actual execution of the SQL statement :shifty:

1 Like

HOW DO YOU MEAN that

You put an sql statement into a variable, then do nothing with it.

2 Likes

what should be

First you need to make a connection to the database.
Then using that connection, you execute the query you stored in the variable.

But because the query contains a variable(which I don’t see being set anywhere) you should really prepare the query first, substituting the variable ($email`) for a parameter.
Then execute it, passing in the value for the parameter.

I’m sure I have seen you do this before in other topics already, you know this.

	$mysqli = new mysqli("", "", "", "");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}
	like this
if (isset($_POST['submit'])) {
	

	


$email = $_SESSION['email'];
    $sql = "UPDATE users SET paid='1' where `email`='".$email."'";

SQL Injection

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.