Jump to content


Photo

Extremely simple CMS with JavaScript and php

home made cms

  • Please log in to reply
No replies to this topic

#1 htakeuchi

htakeuchi

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 15 February 2013 - 12:36 PM

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>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com