TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 03-09-2011, 02:33 PM   #1 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default Creating and calling functions

Ok so now im at the next level where i need to take it to the next step. Over the past i have used Multiple pages for scripts etc.. now what i need to do is put them all on the same page rather than having to redirect place to place then to redirect back to the original page. Only thing is im having trouble on how to construct what i have and looking at examples once again getting confused. So if someone could show me how to construct this.??


Ok so on the main page i have:

PHP Code:
<?php 
$myFile 
"../includes/docs/sdata.txt";
$fh fopen($myFile'r');
$theData fread($fhfilesize($myFile));
fclose($fh);
echo 
'<form action="Scripts/edittemplates.php" method="post" enctype="multipart/form-data"><label for="templateedit">Edit template script</label><br /><textarea name="templateedit" cols="90" rows="20" id="templateedit">' $theData '</textarea><br><br><button>Save Template script</button></form>'
?>
Its basicaly just displaying what i have in that text file... with a button that submits the change. The button takes you to the file Scripts/edittemplates.php which contains the code to edit the file and put on there the new content.

PHP Code:
<?php
//lets delete old file
$myFile "../../includes/docs/sdata.txt";
unlink($myFile);
//now create a new 1
$ourFileName "../../includes/docs/sdata.txt";
$ourFileHandle fopen($ourFileName'w') or die("can't open file");
fclose($ourFileHandle);
//now write the data
$thescript $_REQUEST["templateedit"];
$myFile "../../includes/docs/sdata.txt";
$fh fopen($myFile'a') or die("can't open file");
$stringData "" $thescript "";
fwrite($fh$stringData);
fclose($fh);
//pend to admin log
$ip=$_SERVER['REMOTE_ADDR'];
$myFile "../../includes/docs/adminlog.txt";
$fh fopen($myFile'a') or die("can't open file");
$stringData "<div class='qname'>sb0t Template script edited by: " $ip " at: " date("d-M-Y-h-i-a") . "</div><hr class='custhr' />";
fwrite($fh$stringData);
fclose($fh);
 
header'refresh: 0; url=http://www.sb0t.tentun.co.uk/Admin/edits.php' );
 echo 
'<div class="motdadded"><h3>Template script edited...</h3></div>';
?>

And then redirects back to the original page... so now what i need to do is put this in to the 1 page only but have no idea how to construct it and how to call it from the form so could someone edit this and construct it to see how such a thing would be done? Thanks! would appriciate it a lot so i can see how it works.
Tim Dobson is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Simple Currency Converter with Automatic Symbols Wildhoney General 11 03-16-2010 05:22 PM
How do you access your data in a class? Wildhoney Advanced PHP Programming 4 06-08-2009 10:16 PM
Creating directory hierarchies with ease Wildhoney Script Giveaway 3 12-04-2008 02:28 AM


All times are GMT. The time now is 08:22 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design