使用PHP从Web表单更新数据表

I am new to PHP and there is one problem which I don't understand quite well.

I have web form and text fields. When web form loads text field get data from database.

What I am trying to do is to update databse on buton click, actually on second web form load. But data in database is not changing at all.

$first_name = $_POST[textfield];

session_start();
$telegramNum = $_SESSION[telegramNum]; // This is data from first page, this code is 
                                       // on third page, data was from second page

$testDataQuery="UPDATE person_response SET first_name = ".$first_name." WHERE telegram_number= " .$telegramNum;

Problem was in form tag. I didn't put hole part of code inside form tag.

You should connect to the database and send query. In your code you only assign mysql query to the variable.

First i would read up on some tutorial about connection to database using php. Then learn how to execute queries. Also, read up a little about using mysql_real_escape_string() for data injection.

PHP MySQL connection tutorial

$first_name = $_POST['textfield'];

session_start();
$telegramNum = $_SESSION['telegramNum'];    
$testDataQuery="UPDATE person_response SET first_name = '".$first_name."' WHERE telegram_number= '" .$telegramNum."'";

make sure you use single quote around the data injected in query and also around $_POST and $_SESSION vars

You didn't understand me. I connected with database. When page 2 is loading, text fields is updated with data from database.

But when I change some of that text field and go on another page, in that moment I want to update database with this new data. Connection and everything else is ok.