Hi ... I want to create some php pages where I have to change the variables ( top of the page ) through a form and of course save them on the same page. I don't want to use databases. It's possible???

<?php
$pageurl = "text1";
$title = "text2";
$description = "Desc...Desc.... Desc.........";
$image = "text3";
$price = "12";
$conf = " H 30";
?>

<!DOCTYPE html>
<html lang="it" >

<head>  
<meta charset="UTF-8">

  <title><?php echo $title; ?> | Mysite - Plants collection</title>
  <meta name="description" content="<?php echo $description; ?>">
  <meta property="og:url"           content="https://www.mysite.it/shop/<?php echo $image; ?>.php" />
  <meta property="og:type"          content="product" />
  <meta property="og:title"         content="<?php echo $title; ?>|Site" />
  <meta property="og:description"   content="<?php echo $description; ?> " />
  <meta property="og:image"         content="https://www.mysite.it/images/<?php echo $image; ?>.jpg" />
  <meta property="og:site_name" content="Mysite">

Recommended Answers

All 4 Replies

What do you mean that you want to save the variables on the same page? If you’re referring to having a form where you’re enter data and then hit submit and that data shows up on the page, then yes, there’s no need for a database. But if you want persistent data where once you set it, it always stays even after you refresh/reload the page, or is seen by others, then you need a database to store those values somewhere to be retrieved later or by other people.

If you only need to save the data for the time the user is on that page or site you could always set session variables. But as Dani answered, once the user closes their browser or the session times out the data will be gone without it being in a database. It's not as secure but it could also be written to a text file on the server for use later as well. PHP does this nicely

I can create different pages by user and therefore user should modify variables from other page.
I modified in the following way, inserting a form that onload changes the variables.
But I don't know how to change form data on server from other page.
Here's what I changed:

<?php
$title = $_POST['title'];
$description = $_POST['description'];
$image = $_POST['image'];
$price = $_POST['price'];
$conf = $_POST['conf'];
?>
<!DOCTYPE html>
<html lang="it" >

<head>  
<meta charset="UTF-8">

  <title><?php echo $title; ?> | Mysite - Plants collection</title>
  <meta name="description" content="<?php echo $description; ?>">
  <meta property="og:url"           content="https://www.mysite.it/shop/<?php echo $image; ?>.php" />
  <meta property="og:type"          content="product" />
  <meta property="og:title"         content="<?php echo $title; ?>|Site" />
  <meta property="og:description"   content="<?php echo $description; ?> " />
  <meta property="og:image"         content="https://www.mysite.it/images/<?php echo $image; ?>.jpg" />
  <meta property="og:site_name" content="Mysite">

and the form:

<body onload="submit()">
<form method="post" id="crea" name="crea" class="hide" action=""> 
Title Page:<br> <input type="text" name="title" placeholder="" value="text1"><br>
Image:<br>  <input type="text" name="image" placeholder="" value="text2"><br>
Price:<br>  <input type="text" name="price" placeholder="" value="12"><br>
Conf:<br>  <input type="text" name="conf" placeholder="" value="H 30"><br>
Description<br> <textarea name="description" cols="100" rows="2">Desc...Desc.... Desc......... </textarea>
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.