Jump to content

changing elements of a web page


pwes24

Recommended Posts

Hello everyone.

 

I'd like to create a user friendly admin file where one can change elements like coloron a different web page. For example, to change the background of a web page, the client just logs on to the admin panel and makes the change. How do I write code to go to the web page and update this information permanently?

 

Your help will be apperciated.

Link to comment
https://forums.phpfreaks.com/topic/96843-changing-elements-of-a-web-page/
Share on other sites

Databases.  You would store the background color in somewhere in a MySQL table, then just call it.  ex.

 

<?php
$result=mysql_fetch_array(mysql_query("SELECT bgcolor FROM site_config"));
?>

<body bgcolor="<?php echo $result['bgcolor']; ?>">

 

That's just a quick example.  There's better ways to go about it in the end, but that should give you an idea.

 

As for the admin part you would just have another script that would update that table in the database.  ex.

 

if(isset($_POST['color']) && $_POST['color']!=''){
    $update=mysql_query("UPDATE site_config SET bgcolor='".mysql_real_escape_string($_POST['color'])."'");
}

<form action="update.php" method="post">
Color: <input type="text" name="color">
<input type="submit" value="Update">
</form>

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.