JDST
JDST

Reputation: 15

Change Variable Values by Form

Does anyone know how to change PHP Variable values by HTML Form ? I am using php script to display the values on HTML Pages

but i want to change the values by form not by editing php files but i don't know how to do it


here is my php script [data.php]

    <?php
        $web_title_en = "JDST BLOG"; // Website Title
        $web_subtitle_en = "blah blah blah"; // Website Subtitle
?>

and html (for display the values) [index.html]

<html>
<head>
<?php include 'data.php';?> 
</head>
<body>
<h1><?php echo $web_title_en; ?></h1>
<h4><?php echo $web_subtitle_en; ?></h4>
</body>
</html>

Upvotes: 0

Views: 115

Answers (2)

Alfonso Jim&#233;nez
Alfonso Jim&#233;nez

Reputation: 1245

If you want to process html forms with php you should read this w3c tutorial. Your form would be something like this:

<html>
<body>

<form action="data.php" method="post">
Title: <input type="text" name="title"><br>
Subtitle: <input type="text" name="subtitle"><br>
<input type="submit">
</form>

</body>
</html>

And this would be data.php (a merged version with your index.html)

<?php 
$web_title_en = $_POST['title']; // Website Title
$web_subtitle_en = $_POST['subtitle']; // Website Subtitle
?>
<html>
<body>

<h1><?php echo $web_title_en; ?></h1>
<h4><?php echo $web_subtitle_en; ?></h4>

</body>
</html>

Upvotes: 1

tomsowerby
tomsowerby

Reputation: 498

I'm not sure about your exact situation (perhaps the question could be reworded?), but this might be a useful document on how to handle form data: http://www.w3schools.com/php/php_forms.asp

Upvotes: 0

Related Questions