ja juz nie wiem, pomieszalo mi sie wszystko. prosze. moglbys to dla mnie naprawic?
to jest kod strony editdeletestudent.php: (ladnie pokazuje mi dane z student w tabelce z opcja edit i delete)
<?php
// Connects to your Database
//checks cookies to make sure they are logged in
if (isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password']) {
header("Location: login.php");
}
//otherwise they are shown the admin area
else {
echo "<h1>DELETE/EDIT STUDENTS</h1><p>";
// if result is positive we display content
echo "<table cellpadding=2 border=1>"; echo "<td>" . $row['studentid'] . "</td><td>" . $row['firstname'] . "</td><td>" . $row['surname'] . "</td>"; echo "<td> <a href=deletestudent2.php?a=del&id={$row['studentid']}>DEL</a> <a href=editstudent.php?a=edit&id={$row['studentid']}>EDIT</a></td>";
}
echo "<a href=menu.php><< Back to main menu</a><p>"; }
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>
to jest kod strony deletestudnet.php (kasuje rekordy z tabeli bez problemu):
<?php
// Connects to your Database
//checks cookies to make sure they are logged in
if (isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password']) {
header("Location: login.php");
}
//otherwise they are shown the admin area
else {
if ($a == 'del' and
!empty($id)) { echo "<h1>DELETE STUDENT</h1><p>"; echo 'Record deleted<br>'; echo "<a href=menu.php><< Back to main menu</a><p>"; }
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>
a to jest kod tej nieszczesnej strony editstudent.php (pokazuje dane w formularzu ale jak naciskam update records wywala mi biala strone i dane w bazie sie nie zmieniaja)
<?php
// Connects to your Database
//checks cookies to make sure they are logged in
if (isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password']) {
header("Location: login.php");
}
//otherwise they are shown the admin area
else {
$a = trim($_REQUEST['a']); else
$id = '';
if ($a == 'edit' and
!empty($id)) { studentid='$id'") or
die('Error');
// read content of table
echo "<h1>EDIT STUDENT</h1><p>"; echo '<form action="editstudent.php" method="post"> <input type="hidden" name="a" value="save" />
<input type="hidden" name="studentid" value="' . $id . '" />
First name:<br />
<input type="text" name="firstname"
value="' . $r['firstname'] . '" /><br />
Surname:<br />
<input type="text" name="surname"
value="' . $r['surname'] . '" /><br />
Username:<br />
<input type="text" name="username"
value="' . $r['username'] . '" /><br />
Password:<br />
<input type="text" name="password"
value="' . $r['password'] . '" /><br />
<input type="submit" value="Update Record" />
</form>';
echo "<a href=deletestudent.php><< Back to delete/edit menu</a><p>"; echo "<a href=menu.php><< Back to main menu</a><p>";
}
}
}
}
} elseif ($a == 'save') {
// get the new records from form
$id = $_POST['studentid'];
$firstname = trim($_POST['firstname']); $surname = trim($_POST['surname']); $username = trim($_POST['username']); $password = trim($_POST['password']); // update table
mysql_query("UPDATE studnet SET firstname='$firstname', surname='$surname', username='&username', password='$password' WHERE studentid='$id'") or
die('Error'); }
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>
no i jest to zrobione GETem jednak (chyba sam juz nie wiem). prosze o spojrzenie w kod i pomoc
po usunieciu sprawdzania ciasteczek dziala wszystko ok:
ten kod dziala bez zarzutow ale jak chce sprawdzic ciasta to wywala na koniec pusta strone. jak tu dodac sprawdzanie ciastek teraz? jesli nie ma ciasta ma pokazywac login.php a jak sa to ma pokazywac tresc strony
<?php
// Connects to your Database
$a = trim($_REQUEST['a']); else
$id = '';
if ($a == 'edit' and
!empty($id)) { studentid='$id'") or
die('Error');
// read content of table
echo "<h1>EDIT STUDENT</h1><p>"; echo '<form action="editstudent.php" method="post"> <input type="hidden" name="a" value="save" />
<input type="hidden" name="studentid" value="' . $id . '" />
First name:<br />
<input type="text" name="firstname"
value="' . $r['firstname'] . '" /><br />
Surname:<br />
<input type="text" name="surname"
value="' . $r['surname'] . '" /><br />
Username:<br />
<input type="text" name="username"
value="' . $r['username'] . '" /><br />
Password:<br />
<input type="text" name="password"
value="' . $r['password'] . '" /><br />
<input type="submit" value="save" />
</form>';
}
}
elseif ($a == 'save') {
// get the new records from form
$id = $_POST['studentid'];
$firstname = trim($_POST['firstname']); $surname = trim($_POST['surname']); $username = trim($_POST['username']); $password = trim($_POST['password']); // update table
mysql_query("UPDATE student SET firstname='$firstname', surname='$surname', username='&username', password='$password' WHERE studentid='$id'") or
die('Error'); }
?>