
May 30th, 2003, 06:07 PM
|
|
|
|
Join Date: Apr 2007
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
tutorial question on news script part 1
hello im trying to embedd this script into a page im working on and im wondering if its possible to add another part on the form such as title for the title of the news box as im trying do do here
URL
its hard for me to explain but i added another
php Code:
Original
- php Code |
|
|
|
if(!$HTTP_POST_VARS['title']) { echo "You must enter a title"; }
and for the other part too
but it is not working rightly and i was wondering if anyone could help me
ill show you all of the code
addnews.php code
php Code:
Original
- php Code |
|
|
|
<? if($HTTP_POST_VARS['submit']) { if($HTTP_POST_VARS['password'] == 'test') { if(!$HTTP_POST_VARS['title']) { echo "You must enter a title"; } if(!$HTTP_POST_VARS['name']) { echo "You must enter a name"; } if(!$HTTP_POST_VARS['news']) { echo "You must enter some news"; } if(strstr($HTTP_POST_VARS['title'], "|")) { echo "Name cannot contain the pipe symbol - |"; } if(strstr($HTTP_POST_VARS['name'], "|")) { echo "Name cannot contain the pipe symbol - |"; } if(strstr($HTTP_POST_VARS['news'], "|")) { echo "News cannot contain the pipe symbol - |"; } $fp = fopen('news.txt', 'a'); if(!$fp) { echo "Error opening file!"; } $line = date("m.d.y") . "|" . $HTTP_POST_VARS['name']; $line .= "|" . $HTTP_POST_VARS['news']; $line .= "rn"; echo "Error closing file!"; } } else { echo "Password is incorrect, Please try again!"; } } ?> <FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry"> Title:<BR> <INPUT TYPE="text" SIZE="30" NAME="title"><BR> Your name:<BR> <INPUT TYPE="text" SIZE="30" NAME="name"><BR> The News:<BR> <TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR> News Password:<BR> <INPUT TYPE="password" SIZE="30" NAME="password"><BR> <INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR> </FORM>
here is my news box code
php Code:
Original
- php Code |
|
|
|
<td background="newstitlebar.gif" width="434" height="28"><table width="434" cellpadding="2"><tr><td width="6%"></td><td> <?PHP $data = file('news.txt'); foreach($data as $element) { $element = trim($element); } ?> </td></tr></table></td> </tr> <tr> <td background="newspersonbar.gif" width="434" height="21" valign="top"></td> </tr> <tr> <td background="newspost.gif" width="434"><table width="434" cellpadding="2"><tr><td> <?PHP $data = file('news.txt'); foreach($data as $element) { $element = trim($element); echo $pieces[3] . "<BR>" . "<b>Posted by " . $pieces[2] . " on " . $pieces[1] . "</b><BR><BR>"; } ?> </td></tr></table></td> </tr> <tr> <td background="newsbot.gif" width="434" height="2"></td> </tr> </table>
if anyone could help me i would be grateful 
|