Jump to content

[SOLVED] %22


chwebdesigns

Recommended Posts

I am having a problem again with my PHP code. It is all working fine (thanks to some help off this forum) but when I try typing in a hyperlink or an image address I always get %22 on the end of it? Is there a way of stopping this from happening. It is a news page I have the problems with.

Here is the code from the Add News Page:

<?php 
$pass = md5($HTTP_POST_VARS['password'] ) ;
if($HTTP_POST_VARS['submit']) {
    if($pass == 'password is here') {
        if(strstr($HTTP_POST_VARS['name'],"Select your name")) {
            echo "<h1 align=\"center\">You must select your name <a href=\"javascript:history.back(-1)\"> Go back</a></h1>";
            exit;
        }
if(!$HTTP_POST_VARS['title']) {
echo "<h1 align=\"center\">You must enter a title <a href=\"javascript:history.back(-1)\"> Go back</a></h1>" ;
exit;
}
        if(!$HTTP_POST_VARS['news']) {
            echo "<h1 align=\"center\">You must enter some news <a href=\"javascript:history.back(-1)\"> Go back</a></h1>";
            exit;
        }
        if(strstr($HTTP_POST_VARS['name'],"|")) {
            echo "<h1 align=\"center\">Name cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back </a></h1>";
            exit;
        }
if(strstr($HTTP_POST_VARS['title'],"|")) {
            echo "<h1 align=\"center\">Title cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back </a></h1>";
            exit;
        }
        if(strstr($HTTP_POST_VARS['news'],"|")) {
            echo "<h1 align=\"center\">News cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back</a></h1>";
            exit;
        }
        $fp = fopen('../newsadd.txt','a');
        if(!$fp) {
            echo "<h1 align=\"center\">Error opening file! Please try again. If the error continues please contact the webmaster <a href=\"javascript:history.back(-1)\" Go back</a><br><a href=\"mailto:[email protected]?subject=php error UTKD code 101\"> E-mail the webmaster</a></h1>";
            exit;
        }
        $line = "|" . date("d/m/y") . "|" . $HTTP_POST_VARS['name'];
	$line .= "|" . $HTTP_POST_VARS['title'];
        $line .= "|" . $HTTP_POST_VARS['news'] ;
        $line = str_replace("\r\n","<BR>",$line);
        $line .= "\r\n";
        fwrite($fp, $line);
        if(!fclose($fp)) {
            echo "Error closing file! Please try again. If the error continues please contact the webmaster <a href=\"javascript:history.back(-1)\" Go back</a><br><a href=\"mailto:[email protected]?subject=php error UTKD code 102\"> E-mail the webmaster</a>";
            exit;
        }  echo "<h1>News item added</h1>"   ;   
    } else {
        echo "<h1>Bad Password</h1>";
    }
} 
?>
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry">
  <p align="center"><strong>Your name:</strong><BR>
      <select name="name" id="name">
        <option selected title="select">Select your name</option>
        <option>Cheif Instrucor</option>
        <option>Instructor 1</option>
        <option>Instructor 3</option>
        <option>Webmaster</option>
      </select>
  </p>
  <p align="center"><strong>Title:</strong></p>
  <p align="center"><strong>
    <input name="title" type="text" id="title" value="" size="75" maxlength="100">
  </strong><BR>
    <strong>The News:</strong><BR>
      <TEXTAREA NAME="news" COLS="75" ROWS="5"></TEXTAREA>
    <BR>
    <BR>
    <strong>News Password:</strong><BR>
    <INPUT TYPE="password" SIZE="30" NAME="password">
    <BR>
    <INPUT TYPE="submit" NAME="submit" VALUE="Post it!">
    <BR>
      </p>
</FORM>

And here is the code from the news page (which displays all the news)

<?php
$data = file('newsadd.txt');
$data = array_reverse($data);
foreach($data as $element) {
    $element = trim($element);
    $pieces = explode("|", $element);
    echo "<h3 align=\"center\">" . $pieces[3] . "</h3>" . "" . "<i><h5 align=\"center\">Posted by " . $pieces[2] . " on " . $pieces[1] . "</b></i></h5><p align=\"center\">" . $pieces[4] . "<br><hr><br>" ;
}
?>

 

Thanks for your help

From

Cal

Link to comment
https://forums.phpfreaks.com/topic/53982-solved-22/
Share on other sites

Thanks for that, I'll have to check to see if that works.

If the PHP code works fine on my computers will it work the same on any viewers? I am extremley new to PHP and put together the code from different websites ect. As the code works fine, and it is just what I need. Also I don't have access to mySQL unfortunately, as the server won't allow connections to free sources and it costs way too much to have a mySQL account with them.

Thanks from

Cal

Link to comment
https://forums.phpfreaks.com/topic/53982-solved-22/#findComment-266978
Share on other sites

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.