Jump to content
php.lv forumi

Admin lapa


Zoom

Recommended Posts

Problema: man ir skritpts kurs ir G-book, vins saglab infu uz txt. Sis g-book ir domats flasham, bet man vaiga lai input butu no html admina lapas un output uz flasha. Ar flash zinams, bet es nemaku to php admina lapu uzlikt uz parasta html. Vai kads varetu man palidzet uzraktit skriptu jau gatavu ar visu html, lai es tik iekopetu notpada un parvaidotu pat html.! Un lapa butu gatava. Te bus skripts:

<?php
// If you are using an old version of php, remove the next set of lines.
// or use $HTTP_POST_VARS["..."] instead.
$Submit  = $_POST["Submit"];
$Name 	 = $_POST["Name"];
$Email 	 = $_POST["Email"];
$Website  = $_POST["Website"];
$Comments  = $_POST["Comments"];
$NumLow  = $_REQUEST["NumLow"];
$NumHigh  = $_REQUEST["NumHigh"];

// Replace special characters - you can remove the next 5 lines if wanted.
$Name 	 = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
$Email 	 = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
$Comments	= ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);
$Website  = eregi_replace("http://", "", $Website);
$Website  = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);

// Remove slashes.
$Name 	 = stripslashes($Name);
$Email 	 = stripslashes($Email);
$Website  = stripslashes($Website);
$Comments  = stripslashes($Comments);

// ###################################################################################
// ########## Reading and Writing the new data to the GuestBook Database #############

if ($Submit == "Yes") {
// Next line tells the script which Text file to open.
$filename  = "GuestBook.txt";

// Opens up the file declared above for reading

$fp 	 = fopen( $filename,"r");
$OldData  = fread($fp, 80000);
fclose( $fp );

// Gets the current Date of when the entry was submitted
$Today 	 = (date ("l dS of F Y ( h:i:s A )",time()));

// Puts the recently added data into html format that can be read into the Flash Movie.
// You can change this up and add additional html formating to this area.  For a complete listing of all html tags
// you can use in flash - visit: http://www.macromedia.com/support/flash/ts/documents/htmltext.htm

$Input = "Name: <b>$Name</b><br>Email: <b><u><a href=\"mailto:$Email\">$Email</a></u></b><br>Website: <b><u><a href=\"http://$Website\" target=\"_blank\">$Website</a></u></b><br>Comments: <b>$Comments</b><br><i><font size=\"-1\">Date: $Today</font><br><br>.:::.";

/* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file.  This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file  */

$New = "$Input$OldData";

// Opens and writes the file.

$fp = fopen( $filename,"w");
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000);
fclose( $fp );
}

// ###################################################################################
// ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##



// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";

// Opens up the file declared above for reading

$fp  = fopen( $filename,"r");
$Data  = fread($fp, 800000);
fclose( $fp );

// Splits the Old data into an array anytime it finds the pattern .:::.
$DataArray = split (".:::.", $Data);

// Counts the Number of entries in the GuestBook
$NumEntries = count($DataArray) - 1;

print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
 if (!$DataArray[$n]) {
	 Print "<br><br><b>No More entries</b>";
 exit;
 }
}
?>

Atcerieties ka man uz html vaiga tik input. Paldies pa palidzibu, ceru par sapratni.

Link to comment
Share on other sites

Tad, cik es saprotu - tu gribi shamo izmantot nevis Gbook, bet gan blogam, kuru taisi uz Flash... Tjip tekstu pievienoshanu no citas vietas uztaisiit?

Palasi kaartiigi to to failu - nekaa sarezhgjiita. Pat man, kaa konkreetam iesaaceejam... Bet rakstiit visu rpeikshaa patieshaam nav laika tagad. Varu pamest idejas - ir jaauztaisa forma uz atsevishkja faila [tu, gan, nezin kamdeelj, gribi uz HTML, tev neder PHP???] kur ievades lauki atbilst pieprasītajiem datiem, kas tiek padoti ar POST.

attiecīgi:

$Submit  = $_POST["Submit"];
$Name   = $_POST["Name"];
$Email   = $_POST["Email"];
$Website  = $_POST["Website"];
$Comments  = $_POST["Comments"];

 

Man sanāca šāds failiņš. Ātrumā uzmest...

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pievienot rakstu</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257">
</head>

<body>
<form name="form1" method="post" action="failsKoIposteeji.php">
 <p>    Vārds:
   <input name="Name" type="text" id="Name">
   <br>
   Emails:
   <input name="Email" type="text" id="Email3">
   <br>
   Webs: 
   <input name="Website" type="text" id="Website3">
   <br>
   Raksts<br>
   <textarea name="Comments" id="Comments"></textarea>
   <br>
   <input type="submit" name="Submit" value="Pievienot">
 </p>
</form>
</body>
</html>

Par skaadi nenaaktu kaada identifikaacija, lai kursh katrs nevar pievienot rakstus tavam webam... tas gan uz HTML nebuus risinaams...

Edited by orion
Link to comment
Share on other sites

blin nu gam. Es atveru admin.php lapu, man tur ir lodzins jaunumi un apaksa poga sutit. Es taja lodzina uzrakstu savu sakamo un nospiezu pogu sutit. Man tas text saglabajas txt faila. Tad tas pats skripts atkal to infu nolasa un suta vinu uz flash. Un flash lasa infu kura tika ievadita no admin.php lapas.

Ponel :blink:

man vaiga lai tik lasisana laukums butu uz flash, bet raxtisanas uz admin.php

 

aplukojat ko es gribu

Link to comment
Share on other sites

Ble, apliec submit ar clear pogas vietām, citādi pierasts spiest submit, kreisajā pusē :)

Un palasies vairāk par klienta-servera tehnoloģijām, citādi man liekas tev maza izpratne par to kad un kā php darbojās saņemot/nosūtot datus.

Link to comment
Share on other sites

×
×
  • Create New...