Drivers Profiel maken

Status
Niet open voor verdere reacties.
work in progress.. :)
 
Laatst bewerkt door een moderator:
eindelijk gevonden na minuten zitten te frustreren.
kwam erachter dat ie de datum moet behouden anders doet ie het niet.
waarom weet ik niet want kheb het nu wel gehad om het te onderzoeken maar zijn iets met die if checks :P.
ergens vanaf regel 133. daar zie je iets met datums = id enz..
maar iig hij werkt nu wel zoals je wilt.
zie code.

PHP:
<?php
	# You must set this correctly to a
	# location where you are allowed to
	# create a file! 
	$guestbook = 'guestbook.dat';
	# Choose your own password
	$adminPassword = 'test123';
        # Hide harmless warning messages that confuse users.
        # If you have problems and you don't know why,
        # comment this line out for a while to get more
        # information from PHP
        error_reporting (E_ALL ^ (E_NOTICE | E_WARNING));

	# No changes required below here

	$admin = 0;
	if ($adminPassword == 'CHANGEME') {
		die("You need to change \$adminPassword first.");
	}

	# Undo magic quotes - useless for flat files,
	# and inadequate and therefore dangerous for databases. See:
	# http://www.boutell.com/newfaq/creating/magicquotes.html
	
	function stripslashes_nested($v)
	{
		if (is_array($v)) {
			return array_map('stripslashes_nested', $v);
		} else {
			return stripslashes($v);
		}
	}

	if (get_magic_quotes_gpc()) {
		$_GET = stripslashes_nested($_GET);
		$_POST = stripslashes_nested($_POST);
	}
?>
<html>
<head>
<title>Rally drivers profile page</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<h1 align="center" class="style1">Rally drivers profile page</h1>
<div align="center">
<?php
	$password = "";
	if ($_POST['password'] == $adminPassword) {
		$admin = 1;
		$password = $adminPassword;
	} else if (strlen($_POST['password'])) {
		echo("<h2>Login Failed (Bad Password)</h2>\n");
	}
?>	
<table width="600" border="1" cellpadding="3" cellspacing="3">
<tr>

		<th>
			<span class="style1">Name driver</span>
		</th>
		<th>
			<span class="style1">Since</span>
		</th>
		<th>
			<span class="style1">Country</span>
		</th>
		<th>
			<span class="style1">Co drivers</span>
		</th>
		<th>
			<span class="style1">Latest rally car</span>
		</th>
		
<?php
	if ($admin) {
		echo "<th>Controls</th>";
	}
?>
</tr>
<?php
	if ($_POST['submit']) {
		$file = fopen($guestbook, "a");
		if (!$file) {
			die("Can't write to guestbook file");
		}
		$date = date('F j, Y, g:i a');
		$id = rand();
		
		$driverName = $_POST['driverName'];
		$since = $_POST['since'];
		$country = $_POST['country'];
		$coDrivers = $_POST['coDrivers']; 
		$latestRallyCar = $_POST['latestRallyCar']; 
		
		$driverName = clean($driverName, 40);
		$since = clean($since, 40);
		$country = clean($country, 40);
		$coDrivers = clean($coDrivers, 40);
		$latestRallyCar = clean($latestRallyCar, 40);
		
		fwrite($file, 
			"$date\t$driverName\t$since\t$country\t$coDrivers\t$latestRallyCar\t$id\n");
		fclose($file);	
	}
	$file = fopen($guestbook, 'r');
	$tfile = null;
	$delete = 0;
	$deleteId = '';
	if ($admin && $_POST['delete']) {
		$delete = 1;
		$deleteId = $_POST['id'];
		$tfile = @fopen("$guestbook.tmp", 'w');
		if (!$tfile) {
			die("Can't create temporary file for delete operation");
		}
	}
	if ($file) {
		while (!feof($file)) {
			$line = fgets($file);
			$line = trim($line);
			list ($date, $driverName, $since, $country, $coDrivers, $latestRallyCar, $id) = 
				split("\t", $line, 7);
			if (!strlen($date)) {
				break;
			}
			if (!strlen($id)) {
				// Support my old version
				$id = $date;
			}	
			if ($delete) {
				if ($id == $deleteId) {
					continue;
				} else {
					fwrite($tfile, 
						"$date\t$driverName\t$since\t$country\t$coDrivers\t$latestRallyCar\t$id\n");
				}
			}
			echo "<tr>";
			echo "<td> 	$driverName 	</td>";
			echo "<td> 	$since 			</td>";
			echo "<td> 	$country 		</td>"; 
			echo "<td>	$coDrivers		</td>";
			echo "<td>	$latestRallyCar	</td>";
			
			if ($admin) {
				echo "<td>";
				echo "<form action=\"guestbook.php\" " .
					"method=\"POST\">";
				passwordField();
				hiddenField('id', $id);
				echo "<input type=\"submit\" " .
					"value=\"Delete\" " .
					"name=\"delete\">";
				echo "</form>";
				echo "</td>";
			}
			echo "</tr>\n";
		}
		fclose($file);
		if ($delete) {
			fclose($tfile);
			unlink($guestbook);
			rename("$guestbook.tmp", $guestbook);
		}	
	}
	function clean($name, $max) {
		# Turn tabs and CRs into spaces so they can't 
		# fake other fields or extra entries
		$name = ereg_replace("[[:space:]]", ' ', $name);
		# Escape < > and and & so they 
		# can't mess withour HTML markup
		$name = ereg_replace('&', '&amp;', $name);
		$name = ereg_replace('<', '&lt;', $name);
		$name = ereg_replace('>', '&gt;', $name);
		# Don't allow excessively long entries
		$name = substr($name, 0, $max);
		# Undo PHP's "magic quotes" feature, which has
		# inserted a \ in front of any " characters.
		# We undo this because we're using a file, not a
		# database, so we don't want " escaped. Those
		# using databases should do the opposite:
		# call addslashes if get_magic_quotes_gpc()
		# returns false.
		return $name;
	}
	function passwordField() {
		global $admin;
		global $password;
		if (!$admin) {
			return;
		}
		hiddenField('password', $password);
	}
	function hiddenField($name, $value) {
		echo "<input type=\"hidden\" " .
			"name=\"$name\" value=\"$value\">";
	}
?>
</table>
<?php
	if (!$admin) {
?>
<form action="guestbook.php" method="POST">
<span class="style3">Admin Login</span>
<br>
<input type="password" name="password">
<input type="submit" name="login" value="Log In">
</form>
<?php
	}
?>
<form action="guestbook.php" method="POST">
<table width="600" border="0" cellpadding="5" cellspacing="5">
<tr>
<th>Name driver</th><td><input id="driverName" name="driverName" maxlength="40"></td>
</tr>
<tr>
<th>Since</th><td><input id="since" name="since" maxlength="40"></td>
</tr>
<tr>
<th>Country</th><td><input id="country" name="country" maxlength="40"></td>
</tr>
<tr>
<th>Co drivers</th><td><input id="coDrivers" name="coDrivers" maxlength="40"></td>
</tr>
<tr>
<th>Latest rally car</th><td><input id="latestRallyCar" name="latestRallyCar" maxlength="40"></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="Voeg profiel toe / Add profile">
</th>
</tr>
</table>
<?php
	passwordField();
?>
</form>
</div>
</body>
</html>

kga slapen
Byee VRC
 
Laatst bewerkt door een moderator:
dacht er later nog bij.
date formaat zou ik anders instellen.

dag - maand - jaar tijd24h.
PHP:
date('j-m-Y G:i:s');
Byee VRC

P.S. tevens altijd goed om datum/tijd erin te hebben.
extra info voor jou maar niet voor gebruiker ;)
 
helemaal perfect visha,

alleen het verwijderen van berichten lukt nog niet, ben er al mee aan het klooien alleen wil het niet. kun jij iets vinden in de handleiding over een file aanmaken voor temperanry files?

bedankt
 
Laatst bewerkt door een moderator:
Hey,

ik ben bezig geweest met die delete optie. Ik kan inloggen, dan klik ik op delete.
Dan verdwijnt het bericht. Kijk ik opnieuw op de hoofd pagina en dan staat hij er weer....

Ik heb het volgende verandert in regel 122

$guestbook.tmp verandert naar: guestbook.TMP

Hieronder staat de php code. check anders even.
ww is test123

http://www.rally-web.nl/Guestbook/guestbook.php

PHP:
    }
    $file = fopen($guestbook, 'r');
    $tfile = null;
    $delete = 0;
    $deleteId = '';
    if ($admin && $_POST['delete']) {
        $delete = 1;
        $deleteId = $_POST['id'];
        $tfile = @fopen("guestbook.TMP", 'w');
        if (!$tfile) {
            die("Can't create temporary file for delete operation");
        }
 
Laatst bewerkt door een moderator:
wow, whahah kweet niet wat je gedaan hebt maarre hij verwijderd indd niet meer goed.
btw de tmp in TMP veranderen heeft niet zo heel veel zin denk ik.
wat ik gestuurd had werkte perfect. had het getest. alleen de nieuwe datum niet.
kga er ff weer naar kijke. work in progress...
 
Laatst bewerkt door een moderator:
kweet niet wat je gedaan hebt maar hij werkt bij mij wel.
dit is de nieuwe code met nieuwe datum.
PHP:
<?php
	# You must set this correctly to a
	# location where you are allowed to
	# create a file! 
	$guestbook = 'guestbook.dat';
	# Choose your own password
	$adminPassword = 'test123';
        # Hide harmless warning messages that confuse users.
        # If you have problems and you don't know why,
        # comment this line out for a while to get more
        # information from PHP
        error_reporting (E_ALL ^ (E_NOTICE | E_WARNING));

	# No changes required below here

	$admin = 0;
	if ($adminPassword == 'CHANGEME') {
		die("You need to change \$adminPassword first.");
	}

	# Undo magic quotes - useless for flat files,
	# and inadequate and therefore dangerous for databases. See:
	# http://www.boutell.com/newfaq/creating/magicquotes.html
	
	function stripslashes_nested($v)
	{
		if (is_array($v)) {
			return array_map('stripslashes_nested', $v);
		} else {
			return stripslashes($v);
		}
	}

	if (get_magic_quotes_gpc()) {
		$_GET = stripslashes_nested($_GET);
		$_POST = stripslashes_nested($_POST);
	}
?>
<html>
<head>
<title>Rally drivers profile page</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 9px;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<h1 align="center" class="style1">Rally drivers profile page</h1>
<div align="center">
<?php
	$password = "";
	if ($_POST['password'] == $adminPassword) {
		$admin = 1;
		$password = $adminPassword;
	} else if (strlen($_POST['password'])) {
		echo("<h2>Login Failed (Bad Password)</h2>\n");
	}
?>	
<table width="600" border="1" cellpadding="3" cellspacing="3">
<tr><th width="110"><span class="style1">Date</span></th>
<th width="134"><span class="style1">Name driver</span></th>
<th width="144">Names co drivers</th>
<th width="163"><span class="style1">Latest rally car</span></th>
<?php
	if ($admin) {
		echo "<th>Controls</th>";
	}
?>
</tr>
<?php
	if ($_POST['submit']) {
		$file = fopen($guestbook, "a");
		if (!$file) {
			die("Can't write to guestbook file");
		}
		$date = date('d-m-Y G:i:s');
		
		$id = rand();
		$name = $_POST['name'];
		$email = $_POST['email'];
		$comment = $_POST['comment'];
		$name = clean($name, 40);
		$email = clean($email, 40);
		$comment = clean($comment, 40);
		fwrite($file, 
			"$date\t$name\t$email\t$comment\t$id\n");
		fclose($file);	
	}
	$file = fopen($guestbook, 'r');
	$tfile = null;
	$delete = 0;
	$deleteId = '';
	if ($admin && $_POST['delete']) {
		$delete = 1;
		$deleteId = $_POST['id'];
		$tfile = @fopen("$guestbook.tmp", 'w');
		if (!$tfile) {
			die("Can't create temporary file for delete operation");
		}
	}
	if ($file) {
		while (!feof($file)) {
			$line = fgets($file);
			$line = trim($line);
			list ($date, $name, $email, $comment, $id) = 
				split("\t", $line, 5);
			if (!strlen($date)) {
				break;
			}
			if (!strlen($id)) {
				// Support my old version
				$id = $date;
			}	
			if ($delete) {
				if ($id == $deleteId) {
					continue;
				} else {
					fwrite($tfile, 
						"$date\t$name\t$email\t$comment\t$id\n");
				}
			}
			echo "<tr><td>$date</td><td>$name</td>";
			echo "<td>$email</td><td>$comment</td>";
			if ($admin) {
				echo "<td>";
				echo "<form action=\"guestbook.php\" " .
					"method=\"POST\">";
				passwordField();
				hiddenField('id', $id);
				echo "<input type=\"submit\" " .
					"value=\"Delete\" " .
					"name=\"delete\">";
				echo "</form>";
				echo "</td>";
			}
			echo "</tr>\n";
		}
		fclose($file);
		if ($delete) {
			fclose($tfile);
			unlink($guestbook);
			rename("$guestbook.tmp", $guestbook);
		}	
	}
	function clean($name, $max) {
		# Turn tabs and CRs into spaces so they can't 
		# fake other fields or extra entries
		$name = ereg_replace("[[:space:]]", ' ', $name);
		# Escape < > and and & so they 
		# can't mess withour HTML markup
		$name = ereg_replace('&', '&amp;', $name);
		$name = ereg_replace('<', '&lt;', $name);
		$name = ereg_replace('>', '&gt;', $name);
		# Don't allow excessively long entries
		$name = substr($name, 0, $max);
		# Undo PHP's "magic quotes" feature, which has
		# inserted a \ in front of any " characters.
		# We undo this because we're using a file, not a
		# database, so we don't want " escaped. Those
		# using databases should do the opposite:
		# call addslashes if get_magic_quotes_gpc()
		# returns false.
		return $name;
	}
	function passwordField() {
		global $admin;
		global $password;
		if (!$admin) {
			return;
		}
		hiddenField('password', $password);
	}
	function hiddenField($name, $value) {
		echo "<input type=\"hidden\" " .
			"name=\"$name\" value=\"$value\">";
	}
?>
</table>
<?php
	if (!$admin) {
?>
<form action="guestbook.php" method="POST">
<span class="style3">Admin Login</span>
<br>
<input type="password" name="password">
<input type="submit" name="login" value="Log In">
</form>
<?php
	}
?>
<form action="guestbook.php" method="POST">
<table width="600" border="0" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2"><span class="style1">Maak je profiel hieronder aan. Start here.</span></td>
</tr>
<tr>
<th>Name driver</th><td><input name="name" maxlength="40"></td>
</tr>
<tr>
<th>Names co drivers</th><td><input name="email" maxlength="40"></td>
</tr>
<tr>
<th>Latest rally car</th><td><input name="comment" maxlength="40"></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="Voeg profiel toe / Add profile">
</th>
</tr>
</table>
<?php
	passwordField();
?>
</form>
</div>
</body>
</html>

Tevens heb ik de datum j veranderd naar d omdat je anders cijfers krijgt als 3 ipv 03(dag)
Overschrijf je guestbook.php met deze code en verwijder je guestbook.dat bestand. en je guestbook.tmp(of TMP) bestand.
en probeer het dan vervolgens weer te runnen.
kweet niet of je gekeken heb hoe de code werkt maar voor verwijderen maakt ie een temp bestand aan en is de verwijder toegestaan en vervolgens succes verlopen dan verwijderd hij jouw .dat bestand en maakt er een nieuwe van door de tmp extensie te veranderen naar .dat.

Byee VRC
 
hey,

ik heb verder niks gedaan.... maar dat verwijderen heeft nog nooit gewerkt hoor.

heb jij wel berichten kunnen verwijderen??
 
Laatst bewerkt door een moderator:
nee laten we niet veranderen van script,

we hebben hier een goede :
deze werkt mooi en de invul formulieren lopen ook mooi. het enige wat niet werkt is het verwijderen van die berichten. heel vreemd want het originele script werkt zelfs niet.
beetje prut script, want als hij origineel niet werkt lukt het ons ook niet....

Hieronder staat het script, vanuit hier moeten we maar eens verder werken.
heb je nog gekeken naar het voorbeeld hoe ik de profiel pagina graag wil hebben?
staat op je mail. misschien kun je iets spelen met de opmaak zonder dat hij vreemd gaat reageren ;)

PHP:
<?php
    # You must set this correctly to a
    # location where you are allowed to
    # create a file! 
    $guestbook = 'guestbook.dat';
    # Choose your own password
    $adminPassword = 'test123';
        # Hide harmless warning messages that confuse users.
        # If you have problems and you don't know why,
        # comment this line out for a while to get more
        # information from PHP
        error_reporting (E_ALL ^ (E_NOTICE | E_WARNING));
 
    # No changes required below here
 
    $admin = 0;
    if ($adminPassword == 'CHANGEME') {
        die("You need to change \$adminPassword first.");
    }
 
    # Undo magic quotes - useless for flat files,
    # and inadequate and therefore dangerous for databases. See:
    # http://www.boutell.com/newfaq/creating/magicquotes.html
    
    function stripslashes_nested($v)
    {
        if (is_array($v)) {
            return array_map('stripslashes_nested', $v);
        } else {
            return stripslashes($v);
        }
    }
 
    if (get_magic_quotes_gpc()) {
        $_GET = stripslashes_nested($_GET);
        $_POST = stripslashes_nested($_POST);
    }
?>
<html>
<head>
<title>Rally drivers profile page</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 9px;
    font-weight: bold;
}
-->
</style>
</head>
<body>
<h1 align="center" class="style1">Rally drivers profile page</h1>
<div align="center">
<?php
    $password = "";
    if ($_POST['password'] == $adminPassword) {
        $admin = 1;
        $password = $adminPassword;
    } else if (strlen($_POST['password'])) {
        echo("<h2>Login Failed (Bad Password)</h2>\n");
    }
?>  
<table width="600" border="1" cellpadding="3" cellspacing="3">
<tr>
 
        <th>
            <span class="style1">Name driver</span>
        </th>
        <th>
            <span class="style1">Since</span>
        </th>
        <th>
            <span class="style1">Country</span>
        </th>
        <th>
            <span class="style1">Co drivers</span>
        </th>
        <th>
            <span class="style1">Latest rally car</span>
        </th>
        
<?php
    if ($admin) {
        echo "<th>Controls</th>";
    }
?>
</tr>
<?php
    if ($_POST['submit']) {
        $file = fopen($guestbook, "a");
        if (!$file) {
            die("Can't write to guestbook file");
        }
        $date = date('F j, Y, g:i a');
        $id = rand();
        
        $driverName = $_POST['driverName'];
        $since = $_POST['since'];
        $country = $_POST['country'];
        $coDrivers = $_POST['coDrivers']; 
        $latestRallyCar = $_POST['latestRallyCar']; 
        
        $driverName = clean($driverName, 40);
        $since = clean($since, 40);
        $country = clean($country, 40);
        $coDrivers = clean($coDrivers, 40);
        $latestRallyCar = clean($latestRallyCar, 40);
        
        fwrite($file, 
            "$date\t$driverName\t$since\t$country\t$coDrivers\t$latestRallyCar\t$id\n");
        fclose($file);  
    }
    $file = fopen($guestbook, 'r');
    $tfile = null;
    $delete = 0;
    $deleteId = '';
    if ($admin && $_POST['delete']) {
        $delete = 1;
        $deleteId = $_POST['id'];
        $tfile = @fopen("guestbook.TMP", 'w');
        if (!$tfile) {
            die("Can't create temporary file for delete operation");
        }
    }
    if ($file) {
        while (!feof($file)) {
            $line = fgets($file);
            $line = trim($line);
            list ($date, $driverName, $since, $country, $coDrivers, $latestRallyCar, $id) = 
                split("\t", $line, 7);
            if (!strlen($date)) {
                break;
            }
            if (!strlen($id)) {
                // Support my old version
                $id = $date;
            }   
            if ($delete) {
                if ($id == $deleteId) {
                    continue;
                } else {
                    fwrite($tfile, 
                        "$date\t$driverName\t$since\t$country\t$coDrivers\t$latestRallyCar\t$id\n");
                }
            }
            echo "<tr>";
            echo "<td>  $driverName     </td>";
            echo "<td>  $since          </td>";
            echo "<td>  $country        </td>"; 
            echo "<td>  $coDrivers      </td>";
            echo "<td>  $latestRallyCar </td>";
            
            if ($admin) {
                echo "<td>";
                echo "<form action=\"guestbook.php\" " .
                    "method=\"POST\">";
                passwordField();
                hiddenField('id', $id);
                echo "<input type=\"submit\" " .
                    "value=\"Delete\" " .
                    "name=\"delete\">";
                echo "</form>";
                echo "</td>";
            }
            echo "</tr>\n";
        }
        fclose($file);
        if ($delete) {
            fclose($tfile);
            unlink($guestbook);
            rename("$guestbook.tmp", $guestbook);
        }   
    }
    function clean($name, $max) {
        # Turn tabs and CRs into spaces so they can't 
        # fake other fields or extra entries
        $name = ereg_replace("[[:space:]]", ' ', $name);
        # Escape < > and and & so they 
        # can't mess withour HTML markup
        $name = ereg_replace('&', '&amp;', $name);
        $name = ereg_replace('<', '&lt;', $name);
        $name = ereg_replace('>', '&gt;', $name);
        # Don't allow excessively long entries
        $name = substr($name, 0, $max);
        # Undo PHP's "magic quotes" feature, which has
        # inserted a \ in front of any " characters.
        # We undo this because we're using a file, not a
        # database, so we don't want " escaped. Those
        # using databases should do the opposite:
        # call addslashes if get_magic_quotes_gpc()
        # returns false.
        return $name;
    }
    function passwordField() {
        global $admin;
        global $password;
        if (!$admin) {
            return;
        }
        hiddenField('password', $password);
    }
    function hiddenField($name, $value) {
        echo "<input type=\"hidden\" " .
            "name=\"$name\" value=\"$value\">";
    }
?>
</table>
<?php
    if (!$admin) {
?>
<form action="guestbook.php" method="POST">
<span class="style3">Admin Login</span>
<br>
<input type="password" name="password">
<input type="submit" name="login" value="Log In">
</form>
<?php
    }
?>
<form action="guestbook.php" method="POST">
<table width="600" border="0" cellpadding="5" cellspacing="5">
<tr>
<th>Name driver</th><td><input id="driverName" name="driverName" maxlength="40"></td>
</tr>
<tr>
<th>Since</th><td><input id="since" name="since" maxlength="40"></td>
</tr>
<tr>
<th>Country</th><td><input id="country" name="country" maxlength="40"></td>
</tr>
<tr>
<th>Co drivers</th><td><input id="coDrivers" name="coDrivers" maxlength="40"></td>
</tr>
<tr>
<th>Latest rally car</th><td><input id="latestRallyCar" name="latestRallyCar" maxlength="40"></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="Voeg profiel toe / Add profile">
</th>
</tr>
</table>
<?php
    passwordField();
?>
</form>
</div>
</body>
</html>
 
script heeft altijd goed gewerkt.
waarschijnlijk iets met je rechten systeem
btw late we eerst werkend krijgen dan de opmaak.
want das niet zo moeilijk.

btw probeer ook altijd lokaal te testen
xampp kan je gebruiken
kgebruikte mowes potable. erg handig.
 
Ja hij moet eerst goed werken, hij verwijdert nog steeds geen berichten.
inloggen lukt wel. ww: test123

probeer hem maar:

PHP:
<?php
    # You must set this correctly to a
    # location where you are allowed to
    # create a file! 
    $guestbook = 'guestbook.dat';
    # Choose your own password
    $adminPassword = 'test123';
        # Hide harmless warning messages that confuse users.
        # If you have problems and you don't know why,
        # comment this line out for a while to get more
        # information from PHP
        error_reporting (E_ALL ^ (E_NOTICE | E_WARNING));//!!!security!!!
     # No changes required below here
     $admin = 0;
    if ($adminPassword == 'CHANGEME') {
        die("You need to change \$adminPassword first.");
    }
    # Undo magic quotes - useless for flat files,
    # and inadequate and therefore dangerous for databases. See:
    # http://www.boutell.com/newfaq/creating/magicquotes.html
    function stripslashes_nested($v){
        if (is_array($v)) {
            return array_map('stripslashes_nested', $v);
        } else {
            return stripslashes($v);
        }
    }
    if (get_magic_quotes_gpc()){
        $_GET = stripslashes_nested($_GET);
        $_POST = stripslashes_nested($_POST);
    }
?>
<html>
<head>
<title>Rally drivers profile page</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 9px;
    font-weight: bold;
}
-->
</style>
</head>
<body>
<h1 align="center" class="style1">Rally drivers profile page</h1>
<div align="center">
<?php
    $password = "";
    if ($_POST['password'] == $adminPassword) {
        $admin = 1;
        $password = $adminPassword;
    } else if (strlen($_POST['password'])) {
        echo("<h2>Login Failed (Bad Password)</h2>\n");
    }
?>  
<table width="600" border="1" cellpadding="3" cellspacing="3">
<tr>
        <th>
            <span class="style1">Name driver</span>
        </th>
        <th>
            <span class="style1">Since</span>
        </th>
        <th>
            <span class="style1">Country</span>
        </th>
        <th>
            <span class="style1">Co drivers</span>
        </th>
        <th>
            <span class="style1">Latest rally car</span>
        </th>      
<?php
    if ($admin) {
        echo "<th>Controls</th>";
    }
?>
</tr>
<?php
    if ($_POST['submit']) {
        $file = fopen($guestbook, "a");
        if (!$file) {
            die("Can't write to guestbook file");
        }
        $date = date('F j, Y, g:i a');
        $id = rand();
        $driverName = $_POST['driverName'];
        $since = $_POST['since'];
        $country = $_POST['country'];
        $coDrivers = $_POST['coDrivers']; 
        $latestRallyCar = $_POST['latestRallyCar']; 
        $driverName = clean($driverName, 40);
        $since = clean($since, 40);
        $country = clean($country, 40);
        $coDrivers = clean($coDrivers, 40);
        $latestRallyCar = clean($latestRallyCar, 40);
        fwrite($file, "$date\t$driverName\t$since\t$country\t$coDrivers\t$latestRallyCar\t$id\n");
        fclose($file);  
    }
    $file = fopen($guestbook, 'r');
    $tfile = null;
    $delete = 0;
    $deleteId = '';
    if ($admin && $_POST['delete']) {
        $delete = 1;
        $deleteId = $_POST['id'];
        $tfile = @fopen($guestbook.".tmp", 'w');
        if (!$tfile) {
            die("Can't create temporary file for delete operation");
        }
    }
    if ($file) {
        while (!feof($file)) {
            $line = fgets($file);
            $line = trim($line);
            list ($date, $driverName, $since, $country, $coDrivers, $latestRallyCar, $id) = 
                split("\t", $line, 7);
            if (!strlen($date)) {
                break;
            }
            if (!strlen($id)) {
                // Support my old version
                $id = $date;
            }   
            if ($delete) {
                if ($id == $deleteId) {
                    continue;
                } else {
                    fwrite($tfile, "$date\t$driverName\t$since\t$country\t$coDrivers\t$latestRallyCar\t$id\n");
                }
            }
            echo "<tr>";
            echo "<td>  $driverName     </td>";
            echo "<td>  $since          </td>";
            echo "<td>  $country        </td>"; 
            echo "<td>  $coDrivers      </td>";
            echo "<td>  $latestRallyCar </td>";
            
            if ($admin) {
                echo "<td>";
                echo '<form action="'.$_SERVER["PHP_SELF"].'"method=\"POST\">';
                passwordField();
                hiddenField('id', $id);
                echo "<input type=\"submit\" value=\"Delete\" name=\"delete\">";
                echo "</form>";
                echo "</td>";
            }
            echo "</tr>\n";
        }
        fclose($file);
        if ($delete) {
            fclose($tfile);
            unlink($guestbook);
            rename($guestbook.".tmp", $guestbook);
        }   
    }
    function clean($name, $max) {
        # Turn tabs and CRs into spaces so they can't 
        # fake other fields or extra entries
        $name = ereg_replace("[[:space:]]", ' ', $name);
        # Escape < > and and & so they 
        # can't mess withour HTML markup
        $name = ereg_replace('&', '&amp;', $name);
        $name = ereg_replace('<', '&lt;', $name);
        $name = ereg_replace('>', '&gt;', $name);
        # Don't allow excessively long entries
        $name = substr($name, 0, $max);
        # Undo PHP's "magic quotes" feature, which has
        # inserted a \ in front of any " characters.
        # We undo this because we're using a file, not a
        # database, so we don't want " escaped. Those
        # using databases should do the opposite:
        # call addslashes if get_magic_quotes_gpc()
        # returns false.
        return $name;
    }
    function passwordField() {
        global $admin;
        global $password;
        if (!$admin) {
            return;
        }
        hiddenField('password', $password);
    }
    function hiddenField($name, $value) {
        echo '<input type="hidden" name="'.$name.'" value="$value">';
    }
?>
</table>
<?php
    if (!$admin) {
        ?>
        <form action="<?php print$_SERVER["PHP_SELF"] ?>" method="POST">
        <span class="style3">Admin Login</span>
        <br>
        <input type="password" name="password">
        <input type="submit" name="login" value="Log In">
        </form>
        <?php
    }
?>
<form action="<?php print$_SERVER["PHP_SELF"] ?>" method="POST">
<table width="600" border="0" cellpadding="5" cellspacing="5">
<tr>
<th>Name driver</th><td><input id="driverName" name="driverName" maxlength="40"></td>
</tr>
<tr>
<th>Since</th><td><input id="since" name="since" maxlength="40"></td>
</tr>
<tr>
<th>Country</th><td><input id="country" name="country" maxlength="40"></td>
</tr>
<tr>
<th>Co drivers</th><td><input id="coDrivers" name="coDrivers" maxlength="40"></td>
</tr>
<tr>
<th>Latest rally car</th><td><input id="latestRallyCar" name="latestRallyCar" maxlength="40"></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="Voeg profiel toe / Add profile">
</th>
</tr>
</table>
<?php
    passwordField();
?>
</form>
</div>
</body>
</html>
 
Laatst bewerkt door een moderator:
Kheb nu ff geen pc bij de hand dus kan je script niet testen maar stel je rechten goed in van je server anders doet ie het niet. Als je nix aan het script hebt aangepast dat ik je gestuurd hadan ligt het aan de rechten. Probeer het anders met MoWeS. Zet je guestbook in map www.

Byee VRC
 
heb echt geen idee,
heb de rechten allemaal goed ingesteld, tenminste zover ik weet.
alle rechten op 777 code gezet.
de bestanden van het profiel en de map zelf......
 
Laatst bewerkt door een moderator:
rechten van guestbook.php neemk aan.
en ook van .dat en .tmp op 777?
 
Laatst bewerkt door een moderator:
jep alle bestanden incl de map waar ze in staan, staat op 777

groeten
 
Laatst bewerkt door een moderator:
raar,
doe mowes gebruiken en test daar ;)
 
Laatst bewerkt door een moderator:
mowes??? zegt me helemaal niks.
is dit een test server?

maar het probleem ligt echt in het script op dit moment.
het orgineel werkt gewoon wel.
hieronder heb ik het werkende script gezet. deze doet het helemaal.
alleen staan niet alle vragen er in. de indeling moet het zelfde worden als hier:
http://www.rally-web.nl/Guestbook/guestbook.php

PHP:
<?php
    # You must set this correctly to a
    # location where you are allowed to
    # create a file! 
    $guestbook = 'guestbook.dat';
    # Choose your own password
    $adminPassword = 'test123';
        # Hide harmless warning messages that confuse users.
        # If you have problems and you don't know why,
        # comment this line out for a while to get more
        # information from PHP
        error_reporting (E_ALL ^ (E_NOTICE | E_WARNING));
 
    # No changes required below here
 
    $admin = 0;
    if ($adminPassword == 'CHANGEME') {
        die("You need to change \$adminPassword first.");
    }
 
    # Undo magic quotes - useless for flat files,
    # and inadequate and therefore dangerous for databases. See:
    # http://www.boutell.com/newfaq/creating/magicquotes.html
    
    function stripslashes_nested($v)
    {
        if (is_array($v)) {
            return array_map('stripslashes_nested', $v);
        } else {
            return stripslashes($v);
        }
    }
 
    if (get_magic_quotes_gpc()) {
        $_GET = stripslashes_nested($_GET);
        $_POST = stripslashes_nested($_POST);
    }
?>
<html>
<head>
<title>Really Simple PHP Guestbook</title>
</head>
<body>
<h1 align="center">Really Simple PHP Guestbook</h1>
<div align="center">
<?php
    $password = "";
    if ($_POST['password'] == $adminPassword) {
        $admin = 1;
        $password = $adminPassword;
    } else if (strlen($_POST['password'])) {
        echo("<h2>Login Failed (Bad Password)</h2>\n");
    }
?>  
<table border="0" cellpadding="3" cellspacing="3">
<tr><th>Date</th><th>Name</th><th>Email</th><th>Comment</th>
<?php
    if ($admin) {
        echo "<th>Controls</th>";
    }
?>
</tr>
<?php
    if ($_POST['submit']) {
        $file = fopen($guestbook, "a");
        if (!$file) {
            die("Can't write to guestbook file");
        }
        $date = date('F j, Y, g:i a');
        $id = rand();
        $name = $_POST['name'];
        $email = $_POST['email'];
        $comment = $_POST['comment'];
        $name = clean($name, 40);
        $email = clean($email, 40);
        $comment = clean($comment, 40);
        fwrite($file, 
            "$date\t$name\t$email\t$comment\t$id\n");
        fclose($file);  
    }
    $file = fopen($guestbook, 'r');
    $tfile = null;
    $delete = 0;
    $deleteId = '';
    if ($admin && $_POST['delete']) {
        $delete = 1;
        $deleteId = $_POST['id'];
        $tfile = @fopen("$guestbook.tmp", 'w');
        if (!$tfile) {
            die("Can't create temporary file for delete operation");
        }
    }
    if ($file) {
        while (!feof($file)) {
            $line = fgets($file);
            $line = trim($line);
            list ($date, $name, $email, $comment, $id) = 
                split("\t", $line, 5);
            if (!strlen($date)) {
                break;
            }
            if (!strlen($id)) {
                // Support my old version
                $id = $date;
            }   
            if ($delete) {
                if ($id == $deleteId) {
                    continue;
                } else {
                    fwrite($tfile, 
                        "$date\t$name\t$email\t$comment\t$id\n");
                }
            }
            echo "<tr><td>$date</td><td>$name</td>";
            echo "<td>$email</td><td>$comment</td>";
            if ($admin) {
                echo "<td>";
                echo "<form action=\"guestbook.php\" " .
                    "method=\"POST\">";
                passwordField();
                hiddenField('id', $id);
                echo "<input type=\"submit\" " .
                    "value=\"Delete\" " .
                    "name=\"delete\">";
                echo "</form>";
                echo "</td>";
            }
            echo "</tr>\n";
        }
        fclose($file);
        if ($delete) {
            fclose($tfile);
            unlink($guestbook);
            rename("$guestbook.tmp", $guestbook);
        }   
    }
    function clean($name, $max) {
        # Turn tabs and CRs into spaces so they can't 
        # fake other fields or extra entries
        $name = ereg_replace("[[:space:]]", ' ', $name);
        # Escape < > and and & so they 
        # can't mess withour HTML markup
        $name = ereg_replace('&', '&amp;', $name);
        $name = ereg_replace('<', '&lt;', $name);
        $name = ereg_replace('>', '&gt;', $name);
        # Don't allow excessively long entries
        $name = substr($name, 0, $max);
        # Undo PHP's "magic quotes" feature, which has
        # inserted a \ in front of any " characters.
        # We undo this because we're using a file, not a
        # database, so we don't want " escaped. Those
        # using databases should do the opposite:
        # call addslashes if get_magic_quotes_gpc()
        # returns false.
        return $name;
    }
    function passwordField() {
        global $admin;
        global $password;
        if (!$admin) {
            return;
        }
        hiddenField('password', $password);
    }
    function hiddenField($name, $value) {
        echo "<input type=\"hidden\" " .
            "name=\"$name\" value=\"$value\">";
    }
?>
</table>
<?php
    if (!$admin) {
?>
<form action="guestbook.php" method="POST">
<b>Admin Login</b>
<p>
Admin Password: <input type="password" name="password">
<input type="submit" name="login" value="Log In">
</form>
<?php
    }
?>
<form action="guestbook.php" method="POST">
<table border="0" cellpadding="5" cellspacing="5">
<tr>
<td colspan="2">Sign My Guestbook!</td>
</tr>
<tr>
<th>Name</th><td><input name="name" maxlength="40"></td>
</tr>
<tr>
<th>Email</th><td><input name="email" maxlength="40"></td>
</tr>
<tr>
<th>Comment</th><td><input name="comment" maxlength="40"></td>
</tr>
<tr>
<th colspan="2">
<input type="submit" name="submit" value="Sign the Guestbook">
</th>
</tr>
</table>
<?php
    passwordField();
?>
</form>
</div>
</body>
</html>
 
Laatst bewerkt door een moderator:
wat je me nu stuurt is de script in begin situatie. :?
ik heb deze al voor je aangepast en kga het niet weer opnieuw proggen.
enigste wat mist is de opmaak

kheb het zelf getest en de script werkt.
mowes? als je mijn post had gelezen dan zou je weten dat dit een portable werbserver is.

kheb voor je een pakket klaar gemaakt om te testen
downloadlink : http://www.2shared.com/file/12482289/b9a6b45c/mowes_portable.html

uitleg
downloaden > uitpakken > mowes starten > ga dan naar
http://localhost/guestbook/guestbook.php

test de script.
zoals je gaat zien werkt dit gwn.

Byee VRC
 
visha bedankt voor je bericht.

Wat ik je net stuurde was inderdaad het begin script. Deze werkte gewoon goed.
De test server is inderdaad een makkelijk middel om je script te testen. alleen moet een script niet uitgevoerd worden op je local host maar echt in website.

Het begin script werkt goed op internet server.
Jij hebt toen de script aangepast, en helaas werkte hij toen niet meer.
Ik weet niet wat er is fout gegaan, maar de script die jij als laatste had aangepast werkt gewoon niet op de server. terwijl het begin script wel werkt.

De aangepaste versie verschild dus ten opzichte van het begin script.
ergens moet een fout in zitten.

ik heb hem al door gekeken maar kan zo geen fouten zien, wel kan het misschien liggen aan de extra formulieren die je hebt aangemaakt.

heb jij nog enig idee?
 
Laatst bewerkt door een moderator:
maar heb je deze mowes getest??
want als deze werkt dan zou dit ook meoten werken op een webserver en ligt de fout niet aan het script ;)
verwijder alles van server, reset als dat mogelijk is ofzo en dan weer 1 bestand uploaden => guestbook.php
 
Laatst bewerkt door een moderator:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan