Need a very simple PHP script.

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
harrytheshark
Forum Newbie
Posts: 3
Joined: Sun Apr 05, 2009 5:37 am

Need a very simple PHP script.

Post by harrytheshark »

Hi there,
I'm a cocoa developer and for one of my apps I need to do some server side coding. Problem is, I've no experience with PHP at all.
What I need isn't very complicated (I don't think).
Basically I need to be able to post 2 strings to my website, and then have a page on the site display them.
They need to be saved until 2 other strings are posted to replace them.

For example, if I post "string1" and "string2" to "theFile.php", I would then like a file called "displayTheStrings.html" to just show them in the body of the page. They need to be saved so I can view them when I need to, but then If I post two more strings, the old ones are replaced.

Thanks,
Tom.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Need a very simple PHP script.

Post by greyhoundcode »

Something along these lines?

Code: Select all

<?php
// "theFile.php"
 
$string1 = $_POST['string1'];  // You may wish to carry out some kind
$string2 = $_POST['string2'];  // of validation here, depending on what
                               // you are doing this for
 
// Place the strings amongst some HTML
 
$output = <<<HTML
<html>
<head><title> Display the Strings </title></head>
<body> $string1 $string2 </body>
</html>
HTML;
 
// Spit it out as a static file
 
file_put_contents('displayTheStrings.html', $output);
?>
harrytheshark
Forum Newbie
Posts: 3
Joined: Sun Apr 05, 2009 5:37 am

Re: Need a very simple PHP script.

Post by harrytheshark »

Yeah that's perfect!
Thanks for the help,
Tom.
Post Reply