Solocky, as I understand it, you don't need to pass all those hidden strings in HTML to the client; the user never sees them; they just get written to your text file with the users "say" input embedded, so all those strings only need exist in PHP, not HTML.
Try something like this (off the cuff, not tested):
<?php
// String params (do it like this, or similar for security reasons - ie avoid code injection)
$params = array('say' => 'say'); //add further string params here as necessary.
while( list($var, $param) = @each($params) )
{
if ( isset($HTTP_POST_VARS[$param]) || isset($HTTP_GET_VARS[$param]) )
{
$$var = ( isset($HTTP_POST_VARS[$param]) ) ? htmlspecialchars($HTTP_POST_VARS[$param]) : htmlspecialchars($HTTP_GET_VARS[$param]);
}
else
{
$$var = '';
}
}
// Boolean params (do it like this, or similar for security reasons - ie avoid code injection)
$params = array('submit' => 'submit'); //add further boolean params here as necessary.
while( list($var, $param) = @each($params) )
{
if ( isset($HTTP_POST_VARS[$param]) || isset($HTTP_GET_VARS[$param]) )
{
$$var = true;
}
else
{
$$var = false;
}
}
if ($submit && $say != '') {
$filename = “far.*plx”;
$fn = fopen($filename, “a”);
$myStringArray = array(
'----------------------------------------------------------------------------------------------',
'type=',
'name=',
$say,
'#',
'type=',
'----------------------------------------------------------------------------------------------',
'#',
''
);
fwrite($fn, implode("\n", $myStringArray));
fclose($fn);
}
?>
<html>
<head>
<title>X-BLOG</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form action="myScriptFile.php" method="POST">
SAY WHAT U WILL: <input type="text" name="say" />
<input type="submit" name="submit" value="Write it !" />
</form>
</body>
</html>
As you will see, I've implode()d an array of strings to compose the string that gets written to file. Others may choose to use the str_replace() method. Whatever floats your boat.
ReplacemyScriptFile.php with your actual php filename.
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
OK, I'll turn on my development machine and debug the code .....
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
OK, try this :-
<?php
// String params (do it like this, or similar for security reasons - ie avoid code injection)
$params = array('say' => 'say'); //add further string params here as necessary.
while( list($var, $param) = @each($params) )
{
if ( isset($HTTP_POST_VARS[$param]) || isset($HTTP_GET_VARS[$param]) )
{
$$var = ( isset($HTTP_POST_VARS[$param]) ) ? htmlspecialchars($HTTP_POST_VARS[$param]) : htmlspecialchars($HTTP_GET_VARS[$param]);
}
else
{
$$var = '';
}
}
// Boolean params (do it like this, or similar for security reasons - ie avoid code injection)
$params = array('submit' => 'submit'); //add further boolean params here as necessary.
while( list($var, $param) = @each($params) )
{
if ( isset($HTTP_POST_VARS[$param]) || isset($HTTP_GET_VARS[$param]) )
{
$$var = true;
}
else
{
$$var = false;
}
}
if ($submit && $say != '') {
$filename = 'far.txt';
$fn = fopen($filename, 'a');
$cr = "\r\n";
$myStringArray = array(
'type = ' . $cr,
'name = ' . $say . $cr,
'----------------------------------------------------------------------------------------------' . $cr,
'#' . $cr,
);
fwrite($fn, implode('', $myStringArray));
fclose($fn);
}
?>
<html>
<head>
<title>X-BLOG</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form action="test.php" method="POST">
SAY WHAT U WILL: <input type="text" name="say" />
<input type="submit" name="submit" value="Write it !" />
</form>
</body>
</html>
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
Solocky,
Even better, change the line :-
if ($submit && $say != '') {
to if ($say != '') {
Otherwise the write block will only execute if the user clicks theSubmit button, not if he hits the return key on the keyboard.
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
Solocky,
Another thing ........ your code has smart-quotes in it, which will really screw things up. PHP only understands straight-quotes, "..." and '...' (which behave differently in some circumstances). See the Strings section of the PHP manual.
If you have to use MS Word to edit your code then turn smart-quotes off (somewhere in the preferences). Notepad is better but personally I use FirstPage 2000 by EvrSoft (though the 2006 version has been available for some 3 years now). Once you've used an editor that colour-codes your script, there's no going back.
Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372