Hei alle! Er vel første posten min på forumet 
Har laget en publiseringsløsning som jeg nå driver å konverterer til MySQL, har liten erfaring med MySQL så håper at noen av dere kan sjekke om denne koden er sikker eller ikke
Har laget en publiseringsløsning som jeg nå driver å konverterer til MySQL, har liten erfaring med MySQL så håper at noen av dere kan sjekke om denne koden er sikker eller ikke
PHP:
<?php
session_start();
ini_set('arg_separator.output', '&');
/**
*
* File: adm/inc/new_user.php
* Version 19:56 26.06.2008
* Copyright (c) 2008 Sindre Andre Ditlefsen
* License: http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if($control_panel == "$_SESSION[user_id]" && $new_user == "$_SESSION[user_id]"){
if($action == "add"){
$inp_forename = $_POST['inp_forename'];
$inp_forename = quote_smart($inp_forename);
if(empty($inp_forename)){
$error = "<p><b>Du må fylle inn feltet «Fornavn» før brukeren kan lagres.</p>";
$action = "";
}
$inp_surname = $_POST['inp_surname'];
$inp_surname = quote_smart($inp_surname);
if(empty($inp_surname)){
$error = "<p><b>Du må fylle inn feltet «Etternavn» før brukeren kan lagres.</p>";
$action = "";
}
$inp_email = $_POST['inp_email'];
$inp_email = quote_smart($inp_email);
if(empty($inp_email)){
$error = "<p><b>Du må fylle inn feltet «E-post» før brukeren kan lagres.</p>";
$action = "";
}
$inp_password = $_POST['inp_password'];
$inp_password = quote_smart($inp_password);
if(empty($inp_password)){
$error = "<p><b>Du må fylle inn feltet «Passord» før brukeren kan lagres.</p>";
$action = "";
}
if($error == ""){
// Connect to database
$inp_password_saying = $inp_password;
$inp_password = md5("$inp_password");
mysql_query("INSERT INTO users_basic
(id, forename, surname, email, password) VALUES('', $inp_forename, $inp_surname, $inp_email, '$inp_password') ")
or die(mysql_error());
echo"
<h1>Bruker opprettet</h1>
<p>Informasjon:</p>
<table width=\"100%\">
<tr>
<td class=\"outline\">
<table width=\"100%\" cellspacing=\"1\">
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>Fornavn</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span>$inp_forename</span>
</td>
</tr>
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>Etternavn</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span>$inp_surname</span>
</td>
</tr>
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>E-post</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span>$inp_email</span>
</td>
</tr>
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>Ønsket passord</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span>$inp_password_saying</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p><a href=\"index.php?p=users\">Tilbake</a></p>
";
}
}
if($action == ""){
echo"
<h1>Ny bruker</h1>
<form action=\"?p=new_user&action=add\" method=\"post\" enctype=\"multipart/form-data\">
$error
<table width=\"100%\">
<tr>
<td class=\"outline\">
<table width=\"100%\" cellspacing=\"1\">
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>Fornavn</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span><input type=\"text\" name=\"inp_forename\" value=\"$inp_forename\" size=\"49\" /></span> <span style=\"color:red;\">*</span>
</td>
</tr>
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>Etternavn</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span><input type=\"text\" name=\"inp_surname\" value=\"$inp_surname\" size=\"49\" /></span> <span style=\"color:red;\">*</span>
</td>
</tr>
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>E-post</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span><input type=\"text\" name=\"inp_email\" value=\"$inp_email\" size=\"49\" /></span> <span style=\"color:red;\">*</span>
</td>
</tr>
"; if($style == "bodycell"){$style = "subcell";} else{ $style = "bodycell";} echo"
<tr>
<td class=\"$style\" valign=\"top\">
<span><b>Ønsket passord</b></span>
</td>
<td class=\"$style\" valign=\"top\">
<span><input type=\"text\" name=\"inp_password\" value=\"$inp_password\" size=\"49\" /></span> <span style=\"color:red;\">*</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p><input type=\"submit\" value=\"Lagre\" /></p>
<p><a href=\"index.php?p=users\">Tilbake til brukere</a></p>
</form>
";
}
}
else{
echo"<h1>Tilgang nektet</h1>
<p>Beklager, brukeren din har ikke rettigheter til å benytte seg av denne modulen. Vær vennlig
å kontakt sidens administrator for å få tilgang.</p>
<p><a href=\"index.php?p=manual#403\">Hjelp</a></p>";
}
?>