twinsen60 | Bonjour
j'ai un script en php pour gérer une news (affichage et modification)
news.php => affichage
news.txt => le contenu
news.php?action=admin => pour modifier
J'aimerai que une fois, le contenu modifier, j'aimerai laisser le message "News OK", puis être rediriger automatiquement sur la page principal de mon site :
www.toto.com
Comment faire ?
Code :
- <html>
- <head>
- <style type="text/css">
- <!-- .Style1 { color: #FFFFFF; font-weight: normal; } -->
- </style>
- </head>
- <body>
- <?php $password = "test";
- //CHANGE THE LOGIN PASSWORD
- extract($HTTP_GET_VARS);
- extract($HTTP_POST_VARS);
- if ($action != "admin" && $action != "login" && $action!= "temp3" ){ ?>
- <TABLE width="180" height="140" cellPadding=0 cellSpacing=0 bordercolor="#3860c0" bgcolor=#CCCCCC style="BORDER-RIGHT: #3860c0 0px double; PADDING-RIGHT: 0px; BORDER-TOP: #3860c0 0px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 10px; BACKGROUND-IMAGE: PADDING-BOTTOM: 0px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #3860c0 0px double; WIDTH: 180px; COLOR: #ffffff; PADDING-TOP: 0px; BORDER-BOTTOM: #3860c0 0px double; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-DECORATION: none" >
- <TBODY>
- <TR bgcolor="#3860c0">
- <TD width="180" style="BORDER-RIGHT: #3860c0 0px double; PADDING-RIGHT: 0px; BORDER-TOP: #3860c0 0px double; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 20px; MARGIN: 0px; VERTICAL-ALIGN: center; BORDER-LEFT: #3860c0 0px double; COLOR: #ffffff; LINE-HEIGHT: normal; PADDING-TOP: 0px; BORDER-BOTTOM: #3860c0 0px double; BACKGROUND-REPEAT: repeat-x; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; HEIGHT: 20px; TEXT-DECORATION: none; FONT-SIZE: 10px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, Arial ">
- <div align="center">
- <span class="Style1"> <b>News</b>
- </span>
- </div>
- </TD>
- </TR>
- <TR>
- <TD height="120" style="BORDER-RIGHT: #3860c0 2px double; PADDING-RIGHT: 4px; BACKGROUND-POSITION: center bottom; BORDER-TOP: #3860c0 2px double; PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 10px; PADDING-BOTTOM: 4px; MARGIN: 0px; VERTICAL-ALIGN: top; BORDER-LEFT: #3860c0 2px double; COLOR: #ffffff; LINE-HEIGHT: normal; PADDING-TOP: 4px; BORDER-BOTTOM: #3860c0 2px double; BACKGROUND-REPEAT: repeat-x; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; TEXT-DECORATION: none FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, Arial">
- <MARQUEE onmouseover=this.stop() onmouseout=this.start() scrollAmount=2 direction=up width="100%" height=120><?php $fp = file("news.txt" ); for($i = 0; $i <sizeof($fp);$i++){ echo $fp[$i]."<BR>"; } ?>
- </MARQUEE>
- </TD>
- </TR>
- </TBODY>
- </TABLE>
- <?php } if ($action=="admin" ){ ?>
- <body bgcolor="#ccccc">
- <center>
- <table align=middle><td align=left width=20%>
- <tr>
- <td height="27" colspan="2">
- <FONT SIZE="4" COLOR="#000000">:: Lecteur de News ::</FONT>
- </td>
- <tr>
- <td> </td>
- </tr>
- <tr>
- <form method=post action="?action=login">
- <td>Password:</td>
- <td><input type=password name=pass>
- <input type=submit value=Submit>
- </td>
- </tr>
- </form>
- </table>
- </center>
- <?php } if ($action=="login" ){
- if ($pass==$password){
- echo"Password <b>OK</b>";
- $fd = fopen ("news.txt", "r" );
- $stuff = fread ($fd, filesize ("news.txt" ));
- fclose ($fd); php?>
- <body bgcolor="#ccccc">
- <td height="399" width="100%" valign="top">
- <form method="post" action="?action=temp3&te=news.txt">
- <table width="100%" border="0" cellpadding="5" cellspacing="0">
- <tr>
- <td>
- <b><u>Modification News :</u></b>
- </td>
- </tr>
- <tr>
- <td width="100%">
- <textarea name="cont" cols="36" rows="20">
- <?php echo $stuff ?>
- </textarea>
- </td>
- </tr>
- <tr>
- <td width="86%">
- <input type="submit" name="Submit" value="Enregistrer">
- <input type="button" name="Cancel" value="Annuler" onClick="javascript: history.back(1)">
- </td>
- </tr>
- <tr>
- </tr>
- </table>
- </form>
- <?php }else{ echo "<FONT SIZE=2 COLOR=red>Mauvais Password</FONT>"; } }
- if ($action=="temp3" ) {
- $cont=$HTTP_POST_VARS['cont'];
- $cont=stripslashes($cont);
- $fp = fopen("news.txt", "w" );
- fputs($fp, $cont);
- fputs($fp, "\n" );
- fclose($fp); php?>
- <body bgcolor="#ccccc">
- <BR>News "OK"<BR>
- <?php } ?>
- </body>
- </html>
|
Message édité par twinsen60 le 18-05-2007 à 13:51:52
|