S
S
SVaa2020-05-12 20:15:15
PHP
SVaa, 2020-05-12 20:15:15

How to put a variable in a filename?

The script takes the data from the form and creates a text file in which to write the data with the delimiter ";"
Question: How to force this script to put in the name of this file the phone number that the person entered in the form?

<?php

echo 'Форма успешно отпарвлена!';

$user_name = $_POST['user_name'];

$user_phone = $_POST['user_phone'];

$user_address = $_POST['user_address'];

file_put_contents('/home/misha/html/**********.txt' .$user_name.';'.$user_phone.';'.$user_address. PHP_EOL, FILE_APPEND);



?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2020-05-12
@SVaa

file_put_contents("/home/misha/html/{$user_phone}.txt", "{$user_name};{$user_phone};{$user_address}" . PHP_EOL, FILE_APPEND);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question