|
From: <se...@us...> - 2002-09-03 14:54:07
|
Update of /cvsroot/memship/memship
In directory usw-pr-cvs1:/tmp/cvs-serv10731
Added Files:
newmember.php
Log Message:
Nå funker det å legge til folk. Bare helt basic felt funker, men det er
en smal sak å utvide. Når du prøver å legge til en bruker med samme
navn som en eksiterende bruker, får du opp en liste over disse brukerne
og et spørsmål om du virkelig vil legge til en til.
--- NEW FILE: newmember.php ---
<?php
include("includes/liblogin.php");
include("includes/head.php");
$done = $_POST['done'];
$final = $_POST['final'];
$data = $_POST['data'];
if ($done == "1") print '<h1>Du har registrert dette:</h1>';
else print '<h1>Registrer nytt medlem</h1>';
function make_input($name, $type, $var) {
print "<td with=\"100%\"> $name: </td><td><input type=\"$type\"
name=\"data[$name]\" value=\"$var]\"></td>";
}
print '<table width="100%"><tr><td>
<form action="newmember.php" method="post">
<table><tr><td width=100>';
print "Fornavn:</td><td><input type=\"text\" name=\"data[fornavn]\"
value=\"$data[fornavn]\">";
print '</td></tr><tr><td>';
print "Etternavn:</td><td><input type=\"text\" name=\"data[etternavn]\"
value=\"$data[etternavn]\">";
print '</td></tr><tr><td>';
print "Adresse:</td><td><input type=\"text\" name=\"data[adresse]\"
value=\"$data[adresse]\"></td></tr><tr><td>
Postnr:</td><td><input type=\"text\" size=\"4\"
name=\"data[postnr]\" value=\"$data[postnr]\">
</td></tr><tr><td>
Hjemmetelefon:</td><td><input type=\"text\" name=\"data[telhjem]\">
</td></tr><tr><td>
Jobbtelefon:</td><td><input type=\"text\" name=\"data[teljobb]\">
</td></tr><tr><td>
Mobiltelefon:</td><td><input type=\"text\" name=\"data[telmob]\">
</td></tr><tr><td>
Epost:</td><td><input type=\"text\" name=\"data[epost]\">
</td></tr><tr><td>
Kjønn: </td><td><input type=\"radio\" name=\"data[kjønn]\"
value=\"Gutt\">gutt
<input type=\"radio\" name=\"data[kjønn]\" value=\"Jente\">jente
</td></tr><tr><td>
Gruppe: </td><td>
<input type=\"checkbox\" name=\"data[rv]\" value=\"rv\">RV
<input type=\"checkbox\" name=\"data[ru]\" value=\"ru\">RU
<input type=\"checkbox\" name=\"data[rebell]\" value=\"ru\">Rebell
</td></tr><tr><td>
Skole/jobb:</td><td><input type=\"text\" name=\"data[skolejobb]\">
</td></tr><tr><td>
";
echo" Status:</td><td><select name=\"data[status]\">
<option value=\"medlem\">medlem</option>
<option value=\"kontakt\">kontakt</option>
<option value=\"bøllekontakt\">bøllekontakt</option>
<option value=\"ute\">ute</option>
</td></tr><tr><td>";
?>
Kommentarer:</td><td>
<input type="textarea" name="data[kommentar]">
</td></tr>
</table>
</td><td>
<?php
$forename = $data['fornavn'];
$surname = $data['etternavn'];
$dochanges = true;
if (($done == "1") && !($final == "1")) {
$sql = <<<ENDSQL
SELECT forename, surname, address, postal
FROM member
WHERE forename='$forename'
AND surname='$surname';
ENDSQL;
$result = &$conn->Execute($sql);
if (!$result) print $conn->ErrorMsg();
else if ($result->RecordCount() > 0) {
while (!$result->EOF) {
$sur = $result->fields['surname'];
$fore = $result->fields['forename'];
$addr = $result->fields['address'];
$post = $result->fields['postal'];
print "<p>Konflikt: $sur, $fore, $addr ($post)</p>";
$result->MoveNext();
}
print '<input name="final" type="hidden" value="1">';
print '<input name="done" type="hidden" value="1">';
$final = "0"; /* må trykke igjen */
print "<p>Trykk knappen en gang til for å legge til uansett</p>";
print '<input type="submit" value="Ok">';
} else {
$final = "1";
}
} else {
print '<input name="done" type="hidden" value="1">';
print '<input type="submit">';
} /* end of done but not final */
if ($final == "1") {
$forename = $data['fornavn'];
$surname = $data['etternavn'];
$address = $data['adresse'];
$postal = $data['postnr'];
$sql = <<<ENDSQL
INSERT INTO member (forename, surname, address, postal)
VALUES ('$forename','$surname','$address', '$postal')
ENDSQL;
$conn->debug = 1;
$result = &$conn->Execute($sql);
$conn->debug = 0;
if (!$result) print $conn->ErrorMsg();
}
?>
</td></tr></table>
</form>
<?php
include("includes/tail.php");
?>
|