Jump to content

Extremely simple CMS with JavaScript and php


htakeuchi

Recommended Posts

Hello:

 

This is my first posting, I am fairly new to PHP and Javascript, so please be nice! :)

 

I have a question regarding a "Home Made" CMS for just a couple sections of the HTML on a site.

 

I have managed to obtain the HTML by calling it with "Include"

 

I use a couple forms which will gather the data to use for the change, then obtain the id of the DIV to change, all the changes happen by using some JQuery/Javascript, but since it is made by Javascript, all happens "Client side"... I am stuck here... and would like to see if there is a way to make PHP take the new changes into variables that will then replace the content in the HTML file?

 

Let's say...

 

I have a Fuel Pump and I have published the fuel price on my site...

 

I have to change the price every day... so I want a small "admin portal" where I can type the fuel price and with it submit the changes to the site...

 

 

 

here is the sample code I have been playing with so far...

 

 

<html>

<head>

<link href="test.css" rel="stylesheet" type="text/css">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">

</script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Testing Changes</title>

</head>

<body>

This section has the area you can modify:<br>

<br>

<form method="GET">

Change Fisrt line with: <input type="text" name="gasPrice1"><br>

Change Second line with: <input type="text" name="gasPrice2"><br>

<input type="submit" value="Change!">

</body>

</html>

<?php

echo "<br><br>";

include 'index.html';

echo "<br><br>";

$var1 = $_GET["gasPrice1"];

$var2 = $_GET["gasPrice2"];

echo "<br>";

echo $var1 . " This is the echo from the first Variable";

echo "<br>";

echo $var2 . " This is the echo from the second Variable";

?>

<script>

var gPrice1 = "<?php echo $var1; ?>";

$(document).ready(function(){

$("#text1").text(gPrice1);

});

var gPrice2 = "<?php echo $var2; ?>";

$(document).ready(function(){

$("#text2").text(gPrice2);

});

var txt=document.getElementById("text1").innerHTML;

document.write(txt);

</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.